Submission #3453402


Source Code Expand

/*input
STSTSTST
*/
#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;
  while(i < n){
  	if(s[i] == 'S' && s[i+1] == 'T'){
  		int j= i-1;
  		int k = i+2;
  		ans-=2;
  		while(j > -1 && k < n){
  			if(s[j] == 'S' && s[k] == 'T'){
  				j--;
  				k++;
  				ans-=2;
  			}
  			else{
  				i = k-1;
  				break;
  			}
  		}
  	}
  	i++;
  } 
  cout << ans;
  return 0;
}

Submission Info

Submission Time
Task A - STring
User shashwatchandra
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1095 Byte
Status WA
Exec Time 3 ms
Memory 720 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 2 ms 720 KB
corner1 AC 2 ms 720 KB
corner2 WA 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 WA 3 ms 720 KB
sub_corner0 WA 1 ms 256 KB
sub_corner1 AC 1 ms 256 KB
sub_corner2 WA 1 ms 256 KB
sub_rand0 WA 1 ms 256 KB