Submission #47482493


Source Code Expand

/*
Author : Hocky Yudhiono
Sab 11 Nov 2023 07:11:38 
*/

#include "bits/stdc++.h"
using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> PII;
typedef pair<int, int> pii;
typedef pair<LL, LL> PLL;
typedef pair<LL, LL> pll;
typedef long double ld;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define popf pop_front
#define pf push_front
#define popb pop_back
#define pb push_back
#define fi first
#define se second

const double EPS = 1e-9;
const int INFMEM = 63;

// Do dir^1 to get reverse direction
const int dx[8] = {0,0,1,-1,1,-1,1,-1};
const int dy[8] = {1,-1,0,0,1,-1,-1,1};
const char dch[4] = {'R','L','D','U'};

// Do (dir + 2)%4 to get reverse direction
// const int dx[8] = {-1,0,1,0,-1,1,1,-1};
// const int dy[8] = {0,1,0,-1,1,1,-1,-1};
// const char dch[4] = {'U','R','D','L'};
const double PI = 3.141592653589793;

inline void fasterios(){
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
}
// #define endl '\n'
const int MOD = 1000000007;
// const int MOD = 998244353;

// Don't forget to read all the inputs before returning!!!
int main(){
  fasterios();
  string s; cin >> s;
  stack <char> tmp;
  trav(ch, s){
    if(ch == 'C' && tmp.size() >= 2){
      char b = tmp.top();
      tmp.pop();
      char a = tmp.top();
      if(a == 'A' && b == 'B'){
        tmp.pop();
        continue;
      } else {
        tmp.push(b);
        tmp.push(ch);
      }
    } else {
      tmp.push(ch);
    }
  }
  // cout << tmp.size() << endl;
  string ans;
  while(!tmp.empty()) ans.pb(tmp.top()), tmp.pop();
  reverse(all(ans));
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task D - Take ABC
User hocky
Language C++ 20 (gcc 12.2)
Score 425
Code Size 1876 Byte
Status AC
Exec Time 3 ms
Memory 3860 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 30
Set Name Test Cases
Sample example0.txt, example1.txt, example2.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, example0.txt, example1.txt, example2.txt
Case Name Status Exec Time Memory
000.txt AC 1 ms 3300 KiB
001.txt AC 1 ms 3452 KiB
002.txt AC 1 ms 3444 KiB
003.txt AC 1 ms 3412 KiB
004.txt AC 1 ms 3536 KiB
005.txt AC 2 ms 3540 KiB
006.txt AC 1 ms 3724 KiB
007.txt AC 2 ms 3616 KiB
008.txt AC 2 ms 3812 KiB
009.txt AC 2 ms 3788 KiB
010.txt AC 2 ms 3712 KiB
011.txt AC 3 ms 3772 KiB
012.txt AC 1 ms 3436 KiB
013.txt AC 1 ms 3612 KiB
014.txt AC 3 ms 3860 KiB
015.txt AC 3 ms 3784 KiB
016.txt AC 3 ms 3760 KiB
017.txt AC 2 ms 3548 KiB
018.txt AC 2 ms 3576 KiB
019.txt AC 2 ms 3576 KiB
020.txt AC 2 ms 3536 KiB
021.txt AC 2 ms 3432 KiB
022.txt AC 2 ms 3628 KiB
023.txt AC 2 ms 3568 KiB
024.txt AC 2 ms 3564 KiB
025.txt AC 2 ms 3580 KiB
026.txt AC 3 ms 3852 KiB
example0.txt AC 1 ms 3436 KiB
example1.txt AC 1 ms 3416 KiB
example2.txt AC 1 ms 3448 KiB