Submission #904293


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  string s;
  cin>>s;
  stack<int> S;
  REP(i,s.size()){
    char c = s[i];
    int x = c=='S'?0:1;
    if(S.size()>0 && S.top() == 0 && x==1)S.pop();
    else S.push(x);
  }
  printf("%d\n",S.size());
  return 0;
}

Submission Info

Submission Time
Task A - STring
User rickytheta
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1110 Byte
Status AC
Exec Time 44 ms
Memory 1408 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:44:25: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘std::stack<int>::size_type {aka long unsigned int}’ [-Wformat=]
   printf("%d\n",S.size());
                         ^

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 44 ms 1408 KB
corner1 AC 10 ms 1284 KB
corner2 AC 10 ms 640 KB
example0 AC 2 ms 256 KB
example1 AC 2 ms 256 KB
example2 AC 2 ms 256 KB
handmade0 AC 2 ms 256 KB
handmade1 AC 2 ms 256 KB
maxrand0 AC 10 ms 640 KB
sub_corner0 AC 2 ms 256 KB
sub_corner1 AC 2 ms 256 KB
sub_corner2 AC 2 ms 256 KB
sub_rand0 AC 2 ms 256 KB