Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Baltic ACM ICPC A
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, ac1=0, bc1=0, ac2=0, bc2=0;
- char c[1001];
- cin >> n;
- if(n%2!=0)
- {
- cout << "Impossible" << endl;
- }
- else
- {
- for(int i=0;i<n/2;i++)
- {
- cin >> c[i];
- if(c[i]=='a'){ac1+=1;}
- else if(c[i]=='b'){bc1+=1;}
- }
- for(int j=n/2;j<n;j++)
- {
- cin >> c[j];
- if(c[j]=='a'){ac2+=1;}
- else if(c[j]=='b'){bc2+=1;}
- }
- if((ac1+ac2)%2==0 && (bc1+bc2)%2==0 && ac1==ac2 && bc1==bc2)
- {
- for(int y=0;y<n;y++)
- {
- cout << c[y];
- if(y!=n-1 && y!=(n/2)-1){cout << "+";}
- if(y==(n/2)-1){cout<<"=";}
- }
- }
- else
- {
- cout << "Impossible" << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement