ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1654. Cipher Message

ac 0.015
Posted by Dyryaev Daniil 30 Oct 2019 15:05
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

void optimization() {
     cin.tie(nullptr);
     ios_base::sync_with_stdio(false);
}


int main() {
     optimization();

     string s;
     int k = -1;
     cin >> s;
     char c[200000];

     for (char & i : c) {
          i = ' ';
     }

     for (char i : s) {
          if (k > -1) {
               if (c[k] == i) {
                    c[k] = ' ';
                    k--;
               } else {
                    k++;
                    c[k] = i;
                    continue;
               }
          }
          else {
               k++;
               c[k] = i;
          }
     }
     for (char i : c) {
          if (i != ' ') {
               cout << i;
          }
     }

     return 0;
}