洛谷 P1288 取数游戏II

博弈论……不会……直接看题解……
https://www.luogu.org/blog/user18431/solution-p1288
https://www.luogu.org/blog/fusu2333/solution-p1288

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#define ll long long
#define pii pair<int,int>
#define PINF 0x7fffffff
#define NINF 0x80000000
using namespace std;
int n, arr[22];
int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> arr[i];
    for (int i = 1; i <= n; i++)if (arr[i] == 0) {
        if (i % 2 == 0) {
            cout << "YES";
            return 0;
        }
        break;
    }
    for (int i = n; i >= 1; i--)if (arr[i] == 0) {
        if ((n - i + 1) % 2 == 0) {
            cout << "YES";
            return 0;
        }
        break;
    }
    cout << "NO";
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注