Submission #2243587
Source Code Expand
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <limits> #include <map> #include <stack> #include <unordered_map> #define REP(i,n) for(long (i)=0;(i)<(n);(i)++) #define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++) #define INF numeric_limits<double>::infinity() constexpr long MOD = 1e9 + 7; using namespace std; using P = pair<long, long>; using VI = vector<long>; int main() { string s; cin >> s; stack<char> st; REP(i,s.size()) { if (s[i] == 'T') { if (!st.empty() && st.top() == 'S') { st.pop(); } else { st.push('T'); } } else { st.push('S'); } } cout << st.size() << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | xuzijian629 |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 802 Byte |
Status | AC |
Exec Time | 9 ms |
Memory | 644 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 | 8 ms | 640 KB |
corner1 | AC | 8 ms | 644 KB |
corner2 | AC | 8 ms | 640 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 | AC | 9 ms | 640 KB |
sub_corner0 | AC | 1 ms | 256 KB |
sub_corner1 | AC | 1 ms | 256 KB |
sub_corner2 | AC | 1 ms | 256 KB |
sub_rand0 | AC | 1 ms | 256 KB |