Submission #33617756


Source Code Expand

/*
	Author:Frozencode
*/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pii;
const ll maxn = 200010;
const ll INF = 2147483647;
const ll mod = 998244353;
ll n, l, r;
char ch[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> ch[i];
	ll l = 1, r = n;
	bool flag = true;
	while(l < r - 1){
		if(ch[l] == 'B'){
			break;
		}
		else if(ch[l] == ch[r]){
			if(ch[l + 1] == 'A') ch[l + 1] = 'B';
			l++;
			r--;
		}
		else{
			flag = false;
			break;
		}
	}
	if(l == r - 1 && ch[l] != ch[r]) flag = false;
	cout << (flag ? "Yes" : "No");
	return 0;
}

Submission Info

Submission Time
Task A - AB Palindrome
User Frozencode
Language C++ (GCC 9.2.1)
Score 400
Code Size 746 Byte
Status AC
Exec Time 10 ms
Memory 3792 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 25
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_small_01.txt, 01_small_02.txt, 01_small_03.txt, 01_small_04.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 03_max_01.txt, 03_max_02.txt, 03_max_03.txt, 03_max_04.txt, 03_max_05.txt, 03_max_06.txt, 03_max_07.txt, 03_max_08.txt, 03_max_09.txt, 03_max_10.txt, 03_max_11.txt, 03_max_12.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 6 ms 3548 KiB
00_sample_02.txt AC 2 ms 3560 KiB
01_small_01.txt AC 2 ms 3444 KiB
01_small_02.txt AC 2 ms 3540 KiB
01_small_03.txt AC 2 ms 3420 KiB
01_small_04.txt AC 2 ms 3552 KiB
02_random_01.txt AC 6 ms 3748 KiB
02_random_02.txt AC 7 ms 3648 KiB
02_random_03.txt AC 7 ms 3652 KiB
02_random_04.txt AC 6 ms 3464 KiB
02_random_05.txt AC 9 ms 3792 KiB
02_random_06.txt AC 5 ms 3520 KiB
02_random_07.txt AC 5 ms 3480 KiB
03_max_01.txt AC 7 ms 3604 KiB
03_max_02.txt AC 10 ms 3756 KiB
03_max_03.txt AC 10 ms 3736 KiB
03_max_04.txt AC 8 ms 3736 KiB
03_max_05.txt AC 7 ms 3616 KiB
03_max_06.txt AC 9 ms 3756 KiB
03_max_07.txt AC 9 ms 3756 KiB
03_max_08.txt AC 8 ms 3636 KiB
03_max_09.txt AC 8 ms 3752 KiB
03_max_10.txt AC 9 ms 3632 KiB
03_max_11.txt AC 7 ms 3736 KiB
03_max_12.txt AC 8 ms 3648 KiB