Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- string s;
- cin>>s;
- vector<int> a(n,-1),b(n,-1);
- int left=-1,right=-1;
- for(int i=0;i<n;i++)
- {
- if(s[i]=='-' and left!=-1) b[i]=i-left;
- else if(s[i]=='B') left=i;
- else if(s[i]=='A') left=-1;
- }
- for(int i=n-1;i>=0;i--)
- {
- if(s[i]=='-' and right!=-1) a[i]=right-i;
- else if(s[i]=='B') right=-1;
- else if(s[i]=='A') right=i;
- }
- int votea=0,voteb=0;
- for(int i=0;i<n;i++)
- {
- if(s[i]=='A') votea++;
- else if(s[i]=='B') voteb++;
- else
- {
- if(a[i]==-1 and b[i]==-1) continue;
- else if(a[i]!=-1 and b[i]==-1) votea++;
- else if(b[i]!=-1 and a[i]==-1) voteb++;
- else
- {
- if(a[i]<b[i]) votea++;
- else if(a[i]>b[i]) voteb++;
- }
- }
- }
- if(votea>voteb) cout<<'A';
- else if(votea<voteb) cout<<'B';
- else cout<<"Coalition government";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement