Submission #905105
Source Code Expand
#include <iostream> #include <cstdio> #include <algorithm> #include <ctime> #include <cstdlib> #include <set> #include <map> #include <cmath> #include <vector> #include <queue> #include <stack> #include <cstring> #include <fstream> #include <memory.h> #include <iomanip> #include <omp.h> #include <bitset> #include <string> #include <list> using namespace std; #define right asfdsg #define left asfdsvs #define MAXN 1000000000 #define pb push_back #define F first #define S second #define mp make_pair #define x1 asicvlid #define y1 ascnsdkn typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair < int, int > pii; typedef pair < ll, ll > pll; char s[200500]; int pred[200500]; int nxt[200500]; int n; int getPred(int p) { return pred[p] == p ? p : pred[p] = getPred(pred[p]); } int getNext(int p) { return nxt[p] == p ? p : nxt[p] = getNext(nxt[p]); } int main() { scanf ("%s", s + 1); n = strlen(s + 1); for (int i = 1; i <= n + 1; i ++) pred[i] = i, nxt[i] = i; int b = 1; int e = 2; int cnt = 0; while ( e <= n ) { if (s[b] == 'S' && s[e] == 'T') { pred[b] = getPred(b - 1); nxt[e] = getNext(e + 1); b = pred[b]; e = nxt[e]; cnt += 2; if (b == 0) { b = e; e = getNext(e + 1); } } else { b = getNext(b + 1); e = getNext(e + 1); } } cout << n - cnt; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | rui_de |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1596 Byte |
Status | WA |
Exec Time | 6 ms |
Memory | 2048 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:53:24: 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 | 5 ms | 2048 KB |
corner1 | WA | 5 ms | 2048 KB |
corner2 | WA | 6 ms | 2048 KB |
example0 | AC | 2 ms | 256 KB |
example1 | AC | 2 ms | 256 KB |
example2 | AC | 2 ms | 256 KB |
handmade0 | AC | 3 ms | 256 KB |
handmade1 | AC | 2 ms | 256 KB |
maxrand0 | WA | 6 ms | 2048 KB |
sub_corner0 | WA | 3 ms | 256 KB |
sub_corner1 | WA | 2 ms | 256 KB |
sub_corner2 | WA | 3 ms | 256 KB |
sub_rand0 | WA | 3 ms | 256 KB |