来自某个废物时隔n天的补题
我怎么这么菜.jpg
有了B1的经验,我们很容易想到对于长度奇偶的分类
首先明确两件事情(根据B1):
#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10;
char s[N];
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n;
scanf("%d", &n);
scanf("%s", s + 1);
int cnt = 0, cnt1 = 0;
for (int i = 1; i <= n - i + 1; i++)
if (s[i] != s[n - i + 1])
cnt++;
for (int i = 1; i <= n; i++)
if (s[i] == ‘1‘) cnt1++;
if (n % 2 == 0 || s[n / 2 + 1] == ‘1‘) {
if (cnt == 0) puts("BOB");
else puts("ALICE");
}
else {
if (cnt == 0 && cnt1 == n - 1) puts("BOB");
else if (cnt == 1 && cnt1 == n - 2) puts("DRAW");
else puts("ALICE");
}
}
return 0;
}
Codeforces Round #721 (Div. 2) B2. Palindrome Game (hard version)
原文:https://www.cnblogs.com/cminus/p/14832276.html