Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- char arr[105][10]= {0};
- int cntarr[105][10]= {0};
- int main()
- {
- string s;
- int city=0,i,j,cnt=0,k,ans,mx;
- while(cin>>s)
- {
- if(s[0]=='#')
- break;
- else if(s[0]=='e')
- {
- memset(cntarr,0,sizeof(cntarr));
- ans=0;
- mx=0;
- for(i=0; i<city; i++)
- {
- for(j=0; j<5; j++)
- {
- for(k=0; k<city; k++)
- {
- if(arr[i][j]==arr[k][j])
- cntarr[i][j]++;
- }
- }
- }
- for(i=0;i<city;i++)
- {
- for(j=0;j<5;j++)
- {
- cnt+=cntarr[i][j];
- }
- if(cnt>mx)
- {
- mx=cnt;
- ans=i+1;
- }
- cnt=0;
- }
- cout<<ans<<endl;
- city=0;
- }
- else
- {
- int len=s.length();
- for(i=0; i<len; i++)
- {
- if(s[i]=='r')
- arr[city][0]=s[i+2];
- else if(s[i]=='o')
- arr[city][1]=s[i+2];
- else if(s[i]=='y')
- arr[city][2]=s[i+2];
- else if(s[i]=='g')
- arr[city][3]=s[i+2];
- else if(s[i]=='b')
- arr[city][4]=s[i+2];
- }
- city++;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement