Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- string str;
- while(cin >> str and str[0]!='#')
- {
- vector <char> r,o,y,g,b;
- if(str[0]!='e')
- {
- for(int i=0;i<str.size();i+=4)
- {
- if(str[i]=='r')
- r.push_back(str[i+2]);
- if(str[i]=='o')
- o.push_back(str[i+2]);
- if(str[i]=='y')
- y.push_back(str[i+2]);
- if(str[i]=='g')
- g.push_back(str[i+2]);
- if(str[i]=='b')
- b.push_back(str[i+2]);
- }
- }
- if(str[0]=='e')
- {
- vector <int> changes;
- int lim = r.size(); //every vector size same
- for(int i=0;i<lim;i++)
- {
- int cnt=0;
- for(int j=0;j<lim;j++)
- if(i!=j)
- if(r[i]!=r[j])
- cnt++;
- for(int j=0;j<lim;j++)
- if(i!=j)
- if(o[i]!=o[j])
- cnt++;
- for(int j=0;j<lim;j++)
- if(i!=j)
- if(y[i]!=y[j])
- cnt++;
- for(int j=0;j<lim;j++)
- if(i!=j)
- if(g[i]!=g[j])
- cnt++;
- for(int j=0;j<lim;j++)
- if(i!=j)
- if(b[i]!=b[j])
- cnt++;
- changes.push_back(cnt);
- }
- int mn=1e7;
- //minimum number of changes
- for(int i=0;i<changes.size();i++)
- if(changes[i]<mn)
- mn = changes[i];
- //city that changed minimum according to the statement
- for(int i=0;i<changes.size();i++)
- if(changes[i]==mn)
- cout << i+1 << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement