Submission #1801144


Source Code Expand

#include <bits/stdc++.h>
#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define mod 1000000007
#define inf 1000000000 
#define llinf 1000000000000000000
#define eps 1e-6
#define pi atan(1) * 4
using namespace std;
vector<int> pos;
int main () {
	int a, b, c, d, e, f, g, h, i, j, k, m, n, o, p, q;
	str A, B, C;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> A;
	a = A.length();
	for (i = 0; i < a; i++) {
		if (A[i] != 'x') {
			B += A[i];
			pos.pb(i);
		}
	}
	b = B.length();
	for (i = 0; i < b; i++) {
		if (B[i] != B[b - 1 - i]) {
			printf("-1\n");
			return 0;
		}
	}
	int ans = 0;
	int l, r;
	if (b & 1) {
		l = pos[b >> 1] - 1; r = pos[b >> 1] + 1;
	} else {
		l = pos[b >> 1]; r = pos[(b >> 1) + 1];
	}
	for (i = l, j = r; i >= 0; i--, j++) {
		int m = 0, m2 = 0;
		while (i >= 0 && A[i] == 'x') m++, i--;
		while (j < A.length() && A[j] == 'x') m2++, j++;
		ans += abs(m - m2);
	}
	ans += abs((i + 1) - (a - j));
	printf("%d\n", ans);
	return 0;
}

Submission Info

Submission Time
Task C - Inserting 'x'
User danielykf
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1157 Byte
Status RE
Exec Time 101 ms
Memory 1104 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 4
AC × 23
WA × 5
RE × 5
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 RE 99 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 RE 100 ms 256 KB
1_06.txt AC 3 ms 1104 KB
1_07.txt RE 99 ms 512 KB
1_08.txt WA 3 ms 1104 KB
1_09.txt RE 101 ms 512 KB
1_10.txt AC 2 ms 512 KB
1_11.txt AC 2 ms 512 KB
1_12.txt AC 3 ms 1104 KB
1_13.txt RE 101 ms 512 KB
1_14.txt AC 2 ms 512 KB
1_15.txt WA 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 WA 2 ms 512 KB
1_20.txt AC 2 ms 512 KB
1_21.txt WA 3 ms 592 KB
1_22.txt AC 2 ms 592 KB
1_23.txt AC 3 ms 720 KB
1_24.txt AC 2 ms 720 KB
1_25.txt WA 3 ms 848 KB
1_26.txt AC 2 ms 768 KB
1_27.txt AC 3 ms 1104 KB
1_28.txt AC 2 ms 1104 KB