Educational Codeforces Round 135 (Rated for Div. 2)D. Letter Picking

注意读题,每次拿完之后是放在开头。所以先手不败,因为最后剩下两个的时候,先手一定可以取较小值。

考虑怎样会出现平局?

首先已经知道了先手不败,那么对于后手来说,他追求的就是平局,也就是尽可能的保证每一步都都与先手相同。

所以,如果是回文串,或者两两相同,或者回文串包两两相同的情况,才可以平局。

#include <bits/stdc++.h>

using namespace std;

using vi = vector<int>;


void solve(){
	string s;
	cin >> s;
	int l = 0, r = s.size() - 1;
	while(l < r) {
		if(s[l] == s[r]) l ++, r --;
		else break;
	}
	if(l > r) {
		cout << "Draw\n";
		return;
	}
	while(l < r) {
		if(s[l] == s[l + 1]) l += 2;
		else {
			cout << "Alice\n";
			return;
		}
	}
	cout << "Draw\n";
	return;
}



int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
	int T;
	cin >> T;
	while(T --)
		solve();
	return 0;
}
posted @ 2024-09-20 17:10  PHarr  阅读(3)  评论(0编辑  收藏  举报