Submission #904315
Source Code Expand
//satyaki3794 #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define MOD (1000000007LL) #define LEFT(n) (2*(n)) #define RIGHT(n) (2*(n)+1) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; typedef pair<int, ii> iii; ll pwr(ll base, ll p, ll mod = MOD){ ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans; } ll gcd(ll a, ll b){ if(b == 0) return a; return gcd(b, a%b); } int main(){ ios_base::sync_with_stdio(0); string str; cin>>str; stack<char> st; int n = str.length(); for(int i=0;i<n;i++){ st.push(str[i]); while(1){ if(st.size() < 2) break; char ch = st.top(); st.pop(); if(st.top() == 'S' && ch == 'T'){ st.pop(); continue; } st.push(ch); break; } } cout<<st.size(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | satyaki3794 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1067 Byte |
Status | AC |
Exec Time | 52 ms |
Memory | 1228 KB |
Judge Result
Set Name | Sample | Subtask1 | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 200 / 200 | 100 / 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 | 52 ms | 1228 KB |
corner1 | AC | 5 ms | 720 KB |
corner2 | AC | 5 ms | 720 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 | 6 ms | 720 KB |
sub_corner0 | AC | 2 ms | 256 KB |
sub_corner1 | AC | 2 ms | 256 KB |
sub_corner2 | AC | 3 ms | 256 KB |
sub_rand0 | AC | 3 ms | 256 KB |