AtCoder Grand Contest 005

Submission #1585085

Source codeソースコード

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string x;
  cin >> x;
  stack<char> st;
  rep(i, x.size()) {
    if(x[i] == 'S') st.push(x[i]);
    else if(x[i] == 'T') {
      if(st.empty() || st.top() == 'T') st.push(x[i]);
      else st.pop();
    }
  }
  cout << st.size() << endl;

  return 0;
}

Submission

Task問題 A - STring
User nameユーザ名 uku
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 300
Source lengthソースコード長 930 Byte
File nameファイル名
Exec time実行時間 3 ms
Memory usageメモリ使用量 720 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - example0,example1,example2
Subtask1 200 / 200 example0,example1,example2,sub_corner0,sub_corner1,sub_corner2,sub_rand0,handmade0,handmade1
All 100 / 100 corner0,corner1,corner2,example0,example1,example2,handmade0,handmade1,maxrand0,sub_corner0,sub_corner1,sub_corner2,sub_rand0

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
corner0 AC 2 ms 720 KB
corner1 AC 2 ms 720 KB
corner2 AC 2 ms 720 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 3 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