Submission #904972
Source Code Expand
#include <iostream> #include <iomanip> #include <math.h> #include <map> #include <list> #include <set> #include <vector> #include <stack> #include <queue> #include <algorithm> #include <string> #include <sstream> #include <bitset> #include <string.h> // #include <limits.h> #define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++) #if defined(_MSC_VER) || __cplusplus > 199711L #define AUTOVAR(newvar,v) auto newvar = (v) #else #define AUTOVAR(newvar,v) __typeof(newvar) r = (v) #endif #define PB(x) push_back(x) #define MP(x,y) make_pair((x),(y)) #define MEMSET(m,v) memset(m,v,sizeof(m)) typedef long long ll; typedef unsigned long long ull; #define INTMAX 99999999 #define DEBUG 1 #if DEBUG #define DOUT cout<<"["<<__LINE__<<"]:" #else #define DOUT 0 && cout #endif using namespace std; string X; int main(int argc, char *argv[]) { ios::sync_with_stdio(false); cin >> X; bool updated = true; int numS = X.size()/2; int numT = X.size()/2; while(updated) { updated = false; FOR(i,X.size()) { if(X[i]=='S') { if(X[i+1]=='T') { X.erase(i,2); updated = true; numS--; numT--; if(X[i]=='T') { i-=2; } } else { // 'S' // NOP numS--; } } else { // 'T' // NOP numT--; } } } cout << X.size() << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - STring |
User | creatorstree |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1622 Byte |
Status | AC |
Exec Time | 305 ms |
Memory | 720 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 | 170 ms | 720 KB |
corner1 | AC | 5 ms | 720 KB |
corner2 | AC | 305 ms | 720 KB |
example0 | AC | 3 ms | 256 KB |
example1 | AC | 2 ms | 256 KB |
example2 | AC | 2 ms | 256 KB |
handmade0 | AC | 3 ms | 256 KB |
handmade1 | AC | 3 ms | 256 KB |
maxrand0 | AC | 243 ms | 720 KB |
sub_corner0 | AC | 3 ms | 256 KB |
sub_corner1 | AC | 3 ms | 256 KB |
sub_corner2 | AC | 3 ms | 256 KB |
sub_rand0 | AC | 3 ms | 256 KB |