Submission #905097


Source Code Expand

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(void){
  string S;
  cin >> S;

  int ans=S.size();

  for(int i=0;i<S.size()-1;i++){
    if(S[i] == 'S' && S[i+1] == 'T'){
      int j=0;
      while(S[i-j] == 'S' && S[i+j+1] == 'T' && i-j >= 0 && i+j+1 <= S.size()){
        S[i-j] = 'N';
        S[i+j+1] = 'N';
        j++;
      }
      ans -= 2*j;
    }
  }
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task A - STring
User osatokn
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1768 Byte
Status WA
Exec Time 11 ms
Memory 640 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 100
Status
AC × 3
AC × 6
WA × 3
AC × 7
WA × 6
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 WA 9 ms 640 KB
corner1 AC 9 ms 640 KB
corner2 WA 10 ms 640 KB
example0 AC 3 ms 256 KB
example1 AC 3 ms 256 KB
example2 AC 3 ms 256 KB
handmade0 AC 3 ms 256 KB
handmade1 AC 3 ms 256 KB
maxrand0 WA 11 ms 640 KB
sub_corner0 WA 3 ms 256 KB
sub_corner1 AC 3 ms 256 KB
sub_corner2 WA 3 ms 256 KB
sub_rand0 WA 3 ms 256 KB