Submission #4037713


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* main */

signed main(){
    string s,nox = "";
    cin >> s;
    FOR(i,0,s.size()){
        if(s[i] != 'x')nox += s[i];
    }
    FOR(i,0,nox.size()){
        if(nox[i] != nox[nox.size()-1-i]){
            cout << -1 << endl;
            return 0;
        }
    }
    ll counter[nox.size()+1] = {0};
    ll idx = 0;
    FOR(i,0,s.size()){
        if(s[i] != 'x')idx++;
        else counter[idx]++;
    }
    ll ans = 0;
    FOR(i,0,nox.size()+1){
        ans += abs(counter[i]-counter[nox.size()-i]);
    }
    cout << ans/2 << endl;
}

Submission Info

Submission Time
Task C - Inserting 'x'
User nu50218
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2390 Byte
Status AC
Exec Time 3 ms
Memory 1360 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 33
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 1 ms 256 KB
0_01.txt AC 1 ms 256 KB
0_02.txt AC 1 ms 256 KB
0_03.txt AC 1 ms 256 KB
1_00.txt AC 1 ms 256 KB
1_01.txt AC 1 ms 256 KB
1_02.txt AC 1 ms 256 KB
1_03.txt AC 1 ms 256 KB
1_04.txt AC 1 ms 256 KB
1_05.txt AC 1 ms 256 KB
1_06.txt AC 3 ms 1360 KB
1_07.txt AC 2 ms 512 KB
1_08.txt AC 3 ms 1360 KB
1_09.txt AC 2 ms 512 KB
1_10.txt AC 2 ms 512 KB
1_11.txt AC 2 ms 512 KB
1_12.txt AC 2 ms 1104 KB
1_13.txt AC 2 ms 512 KB
1_14.txt AC 2 ms 512 KB
1_15.txt AC 2 ms 512 KB
1_16.txt AC 2 ms 512 KB
1_17.txt AC 2 ms 512 KB
1_18.txt AC 2 ms 512 KB
1_19.txt AC 2 ms 512 KB
1_20.txt AC 2 ms 512 KB
1_21.txt AC 2 ms 720 KB
1_22.txt AC 2 ms 512 KB
1_23.txt AC 3 ms 720 KB
1_24.txt AC 2 ms 512 KB
1_25.txt AC 3 ms 848 KB
1_26.txt AC 2 ms 512 KB
1_27.txt AC 3 ms 1360 KB
1_28.txt AC 2 ms 592 KB