Submission #904968
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define ll long long int #define pb push_back #define mp make_pair #define inf 0x7fffffff #define inff 100000 #define ff first #define ss second #define sz(x) ((int) (x).size()) #define fast cin.sync_with_stdio(0);cin.tie(0) #define rep(i,N) for(int i = 0;i < N;i++) #define frep(i,a,b) for(int i = a;i <= b;i++) #define pii pair<int , int> #define pll pair<ll , ll> #define vii vector<int> #define vpii vector< pii > #define fill(A,v) memset(A,v,sizeof(A)) #define setbits(x) __builtin_popcountll(x) #define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n" #define all(x) (x).begin(), (x).end() #define gcd __gcd #define SQRT 350 #define CASES int t;cin>>t;while(t--) #define FILE freopen("inp.txt" , "r" , stdin); #define ld long double const int MOD = 1e9 + 7; const int N = 1e6 + 500; const int lgN = 20; const ll INF = 1e16; int main(int argc, char const *argv[]) { fast; string s; cin >> s; //finally string will be of the form TTTSSS.. int ans = 0; while (s.size() > 0) { if ( *(s.begin()) == 'T') { ans++; s.erase(s.begin()); } else break; } while (s.size() > 0) { if ( *(s.end() - 1) == 'S') { ans++; s.erase(s.end() - 1); } else break; } int a = 0 , b = 0; for(auto c : s) if(c == 'T') a++; else b++; ans += max(a , b) - min(a , b); cout << ans << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | dhruvsrivastava |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1472 Byte |
Status | WA |
Exec Time | 16 ms |
Memory | 720 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | 0 / 100 | ||||||||||
Status |
|
|
|
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 | 4 ms | 720 KB |
corner1 | WA | 7 ms | 720 KB |
corner2 | WA | 16 ms | 720 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 | 4 ms | 720 KB |
sub_corner0 | AC | 3 ms | 256 KB |
sub_corner1 | WA | 3 ms | 256 KB |
sub_corner2 | WA | 3 ms | 256 KB |
sub_rand0 | WA | 3 ms | 256 KB |