Submission #1694209
Source Code Expand
//2017-10-19 //miaomiao // #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> using namespace std; #define For(i, a, b) for(int i = (a); i <= (int)(b); ++i) #define N (200000+5) char s[N]; int lst[N], nxt[N]; int main(){ scanf("%s", s+1); int n = strlen(s+1); For(i, 1, n) lst[i] = i-1, nxt[i] = i+1; nxt[n] = 0; int st = -1; For(i, 1, n-1) if(s[i] == 'S' && s[i+1] == 'T'){ st = i; break; } int ans = n, p; while(st != -1){ ans -= 2; if(!lst[st] && !nxt[nxt[st]]) break; if(lst[st]) p = lst[st], nxt[p] = nxt[nxt[st]]; else p = nxt[nxt[st]], lst[p] = 0; while(nxt[p] && (s[p]!='S' || s[nxt[p]]!='T')) p = nxt[p]; st = nxt[p]? p: -1; } printf("%d\n", ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | miaomiao |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 817 Byte |
Status | WA |
Exec Time | 4 ms |
Memory | 2048 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:20:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", s+1); ^
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 | 3 ms | 2048 KB |
corner1 | AC | 3 ms | 2048 KB |
corner2 | WA | 3 ms | 2048 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 | 4 ms | 2048 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 |