Submission #2097147


Source Code Expand

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
 <url:https://agc005.contest.atcoder.jp/tasks/agc005_a>
 問題文============================================================
 文字列 X が与えられます。X の長さは偶数であり、半分は S 、もう半分は T からなります。
 
 高橋君は ST という文字列が苦手です。なので以下の操作を 10^10000 回行うことにしました。
 
 X の(連続な)部分文字列で ST となるもののうち、最も左側にあるものを取り除く。存在しないならば何もしない。
 最終的に X は何文字になるかを求めてください。
 
 =================================================================
 
 解説=============================================================
 
 ================================================================
 */
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    string X; cin >> X;
    stack<string> st;
    for(int i = 0; i < (int)X.length(); i++){
        if(X[i] == 'S') st.push("S");
        else{
            if(!st.empty()){
                string c = st.top();
                if(c == "S") {
                    st.pop();
                    continue;
                }
            }
            st.push("T");
        }
    }
    cout << st.size() << endl;
    return 0;
}

Submission Info

Submission Time
Task A - STring
User clavis1107
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1510 Byte
Status AC
Exec Time 19 ms
Memory 11412 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 200 / 200 100 / 100
Status
AC × 3
AC × 9
AC × 13
Set Name Test Cases
Sample example0, example1, example2
Subtask1 example0, example1, example2, sub_corner0, sub_corner1, sub_corner2, sub_rand0, handmade0, handmade1
All corner0, corner1, corner2, example0, example1, example2, handmade0, handmade1, maxrand0, sub_corner0, sub_corner1, sub_corner2, sub_rand0
Case Name Status Exec Time Memory
corner0 AC 11 ms 5908 KB
corner1 AC 19 ms 11412 KB
corner2 AC 10 ms 1556 KB
example0 AC 1 ms 256 KB
example1 AC 1 ms 256 KB
example2 AC 1 ms 256 KB
handmade0 AC 1 ms 256 KB
handmade1 AC 1 ms 256 KB
maxrand0 AC 10 ms 720 KB
sub_corner0 AC 1 ms 256 KB
sub_corner1 AC 1 ms 256 KB
sub_corner2 AC 1 ms 256 KB
sub_rand0 AC 1 ms 256 KB