Submission #2212060
Source Code Expand
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for (int i=0;i<(n);i++) #define int long long signed main(){ int Ans=0; string S,T,U; cin >> S; int p[114514]={}; int q[114514]={}; int j=0,k=0; T=S; REP(i,T.size()){ if(T[i]=='x'){ T.erase(T.begin()+i,T.begin()+i+1); i--; } } U=T; reverse(U.begin(),U.end()); if(T!=U){ cout << -1 << endl; return 0; } U=S; reverse(U.begin(),U.end()); REP(i,S.size()){ if(S[i]=='x'){ p[j]++; }else{ j++; } if(U[i]=='x'){ q[k]++; }else{ k++; } } REP(i,j+1){ Ans+=max((int)0,p[i]-q[i]); } cout <<Ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - Inserting 'x' |
User | x0214sh7 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 870 Byte |
Status | AC |
Exec Time | 173 ms |
Memory | 2304 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 2 ms | 2048 KB |
0_01.txt | AC | 2 ms | 2048 KB |
0_02.txt | AC | 2 ms | 2048 KB |
0_03.txt | AC | 2 ms | 2048 KB |
1_00.txt | AC | 2 ms | 2048 KB |
1_01.txt | AC | 2 ms | 2048 KB |
1_02.txt | AC | 2 ms | 2048 KB |
1_03.txt | AC | 2 ms | 2048 KB |
1_04.txt | AC | 2 ms | 2048 KB |
1_05.txt | AC | 2 ms | 2048 KB |
1_06.txt | AC | 6 ms | 2304 KB |
1_07.txt | AC | 172 ms | 2304 KB |
1_08.txt | AC | 6 ms | 2304 KB |
1_09.txt | AC | 172 ms | 2304 KB |
1_10.txt | AC | 173 ms | 2304 KB |
1_11.txt | AC | 172 ms | 2304 KB |
1_12.txt | AC | 62 ms | 2304 KB |
1_13.txt | AC | 171 ms | 2304 KB |
1_14.txt | AC | 167 ms | 2304 KB |
1_15.txt | AC | 171 ms | 2304 KB |
1_16.txt | AC | 169 ms | 2304 KB |
1_17.txt | AC | 171 ms | 2304 KB |
1_18.txt | AC | 168 ms | 2304 KB |
1_19.txt | AC | 168 ms | 2304 KB |
1_20.txt | AC | 166 ms | 2304 KB |
1_21.txt | AC | 132 ms | 2304 KB |
1_22.txt | AC | 129 ms | 2304 KB |
1_23.txt | AC | 117 ms | 2304 KB |
1_24.txt | AC | 115 ms | 2304 KB |
1_25.txt | AC | 90 ms | 2304 KB |
1_26.txt | AC | 84 ms | 2304 KB |
1_27.txt | AC | 6 ms | 2304 KB |
1_28.txt | AC | 5 ms | 2304 KB |