Submission #3451222


Source Code Expand

#include<bits/stdc++.h>
#include <unistd.h>
#include <random>
using namespace std;

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string X;
    cin >> X;
    int count = X.size();
    for(int i = 0;i < X.size()-1;i++){
        if(X.at(i) == 'S' && X.at(i+1) == 'T'){
//            cout << i << " and " << i+1 << " is ST!" << endl;
            X.at(i) = '#';
            X.at(i+1) = '#';
            count -= 2;
            for(int j = 1;true;j++){
                if(i - j < 0){
                    break;
                }
                if(X.at(i - j) == '#'){
                    continue;
                }
                for(int k = 1;true;k++){
//                    cout << "J = " << j << endl;
                    if(i + k + 1 >= X.size() || i - j < 0){
                        break;
                    }
                    if(i + k + 1 == '#'){
                        continue;
                    }
//                    cout << "K = " << k << endl;
                    if(X.at(i - j) == 'S' && X.at(i+k+1) == 'T'){
//                        cout << i-j << " and " << i+k+1 << " is ST!" << endl;
                        X.at(i - j) = '#';
                        X.at(i + k + 1) = '#';
                        count -= 2;
                        while(true){
                            j++;
                            if(i - j >= 0 && X.at(i-j) == '#'){
                                continue;
                            }
                            else{
                                break;
                            }
                        }
                    }
                    break;
                }
                break;
            }
        }
    }
    cout << count << endl;
}

Submission Info

Submission Time
Task A - STring
User MEGANEnoKAMISAMA
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2653 Byte
Status WA
Exec Time 4 ms
Memory 720 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 100
Status
AC × 3
AC × 6
WA × 3
AC × 7
WA × 6
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 2 ms 720 KB
corner1 AC 2 ms 720 KB
corner2 WA 3 ms 720 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 720 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