呵呵,哭了

#include <vector>
#include <iostream>
#include <string>
#include <stdlib.h>


using namespace std;


int n1,n2,n3;


int vv1,vv2,w1,w2,w3;


vector<int> v1{0,0,0};
vector<int> v2{0,0,0};


bool equal(vector<int> &vec1,vector<int> &vec2)
{
v1.clear();
v2.clear();
for(auto v:vec1)
v1.push_back(v);
for(auto v:vec2)
v2.push_back(v);


sort(v1.begin(),v1.end());
sort(v2.begin(),v2.end());


w1=v2[1]-v2[0];
w2=v2[2]-v2[1];
w3=v2[2]-v2[0];


if((w1==v1[0]&&w2==v1[1]&&w3==v1[2]&&v2[0]!=0&&v2[1]!=0&&v2[2]!=0)||
(w1=v1[1]&&w2==v1[0]&&w3==v1[2]&&v2[0]!=0&&v2[1]!=0&&v2[2]!=0))


return true;
else
return false;
}


vector<int> docount(string &s)
{
n1=0;
n2=0;
n3=0;
for(auto word:s)
{
if(word=='R')
n1++;
if(word=='Y')
n2++;
if(word=='B')
n3++;
}
vector<int> num{n1,n2,n3};
return num;


}


int main()
{
vector<int> vec1;
vector<int> vec2;
int v;
int N;
int ret=0;
while(cin>>v)
vec1.push_back(v);
    string word;
    cin.clear();
    cin>>word;
    N=word.length();
    string temp;
    int index=0;int step=2;
    int ret2=2;


    while(index+step<=N)
    {
    temp=word.substr(index,step);
    vec2=docount(temp);
    if(equal(vec1,vec2))
    {
    if(ret<ret2)
    ret=ret2;
    cout<<temp<<endl;
    index=index+step;
    step=2;
    ret2=2;
    }


    if(!equal(vec1,vec2))
    {
    step++;
    ret2++;
    }


    }
    ret2--;


    if (ret<ret2)
    ret=ret2;


    cout<<ret<<endl;


}







你可能感兴趣的:(呵呵,哭了)