Submission #1587837
Source Code Expand
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<stack> using namespace std; #define REP(i,n) for(int i=0;(i)<(n);(i)++) #define ll long long int main() { string s; cin >> s; int len = s.length(); int ns = 0; int cnt = 0; int bef = 0;//前のiで消去がおこなわれたか REP(i, len) { if (s[i] == 'S') { if(bef==0) ns++;//Sを蓄える else { ns = 1; bef = 0; } } if (s[i] == 'T') { if (ns > 0) {//消去を行う ns--; cnt++; bef = 1; } else {//Sのたくわえを消す //ns = 0; bef = 0; } } } cout << len - 2 * cnt << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | takiteke |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 798 Byte |
Status | WA |
Exec Time | 8 ms |
Memory | 640 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 | WA | 8 ms | 640 KB |
corner1 | AC | 8 ms | 640 KB |
corner2 | WA | 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 | WA | 8 ms | 640 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 |