fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int n,top=0;
  4. int main(){
  5. scanf("%d",&n);
  6. string s;
  7. cin>>s[++top];
  8. for(int i=2;i<=n;i++){
  9. char a;
  10. scanf("%c",&a);
  11. if(a==s[top]) top--;
  12. else s[++top]=a;
  13. }
  14. if(top!=0) for(int i=1;i<=top;i++) cout<<s[i];
  15. return 0;
  16. }
Success #stdin #stdout 0s 5320KB
stdin
9
acccabddb





stdout
aca