Submission #3453454


Source Code Expand

/*input
SSTSTT
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double

typedef pair<int,int> pi;

typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define mp make_pair
#define pb push_back

#define gcd __gcd

const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

signed main(){
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  int ans = n;
  int i = 0;
  stack<char> a;
  while(i < n){
  	if(s[i] == 'T' && a.top() == 'S')a.pop();
    else a.push(s[i]);
  	i++;
  } 
  cout << a.size();
  return 0;
}

Submission Info

Submission Time
Task A - STring
User shashwatchandra
Language C++14 (GCC 5.4.1)
Score 0
Code Size 923 Byte
Status RE
Exec Time 96 ms
Memory 720 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 100
Status
AC × 1
RE × 2
AC × 3
RE × 6
AC × 7
RE × 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 AC 2 ms 720 KB
corner1 AC 2 ms 720 KB
corner2 AC 2 ms 720 KB
example0 RE 96 ms 256 KB
example1 AC 1 ms 256 KB
example2 RE 96 ms 256 KB
handmade0 AC 1 ms 256 KB
handmade1 RE 96 ms 256 KB
maxrand0 AC 3 ms 720 KB
sub_corner0 AC 1 ms 256 KB
sub_corner1 RE 96 ms 256 KB
sub_corner2 RE 96 ms 256 KB
sub_rand0 RE 96 ms 256 KB