Submission #1354672
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++) #define SZ(v) ((int)(v).size()) #define ALL(v) (v).begin(),(v).end() #define one first #define two second typedef long long ll; typedef pair<int, int> pi; const int INF = 0x3f2f1f0f; const ll LINF = 1ll * INF * INF; const int MAX_N = 2e5 + 100; char S[MAX_N]; int N, Nt[MAX_N], Pr[MAX_N]; bool Chk[MAX_N]; int Ans; int main() { scanf("%s", S+1); N = strlen(S+1); Ans = N; for(int i=1; i<=N; i++) Nt[i] = i+1, Pr[i] = i-1; for(int i=1; i<=N; ) { if(Chk[i]) continue; int a = i, b = Nt[i]; if(b > N) break; if(S[a] == 'S' && S[b] == 'T') { Chk[a] = Chk[b] = true; Ans -= 2; Nt[Pr[a]] = Nt[b]; Pr[Nt[b]] = Pr[a]; i = Pr[a]; }else i = Nt[a]; } printf("%d\n", Ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | kajebiii |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 899 Byte |
Status | AC |
Exec Time | 4 ms |
Memory | 2176 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:21:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s", S+1); N = strlen(S+1); Ans = N; ^
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 | 3 ms | 2176 KB |
corner1 | AC | 3 ms | 2176 KB |
corner2 | AC | 4 ms | 2176 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 | 4 ms | 2176 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 |