首页 > 其他 > 详细

Codeforces Round #721 (Div. 2)

时间:2021-05-25 23:49:40      阅读:26      评论:0      收藏:0      [点我收藏+]

B1. Palindrome Game (easy version)

博弈,如果有偶数个0,A选完后,B选对称的,A就只能再选。直到最后剩2个,此时A选完后,B翻转。

如果有奇数个0,A首先选中间的0,然后情况类似。

技术分享图片
 1 char s[N];
 2 int main()
 3 {
 4     ios::sync_with_stdio(false); cin.tie(nullptr);
 5  
 6     int t;
 7     cin >> t;
 8     while (t--) {
 9         int n;
10         cin >> n;
11         int sum = 0;
12  
13         for (int i = 1; i <= n; i++) {
14             cin >> s[i];
15             if (s[i] == 0)
16                 sum++;
17         }
18         if (sum == 1) {
19             cout << "BOB" << endl;
20             continue;
21         }
22         if (sum % 2) {
23             cout << "ALICE";
24         }
25         else
26             cout << "BOB";
27         cout << endl;
28     }
29 }
View Code

 

Codeforces Round #721 (Div. 2)

原文:https://www.cnblogs.com/lingshi321/p/14810601.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!