其他分享
首页 > 其他分享> > NC20241 [SCOI2005]扫雷MINE

NC20241 [SCOI2005]扫雷MINE

作者:互联网

题目

1.题目大意

2.题目分析

3.题目代码

#include <bits/stdc++.h>
#define N 10000
using namespace std;

int n;
int mine[N];
int num[N];

int deduce()
{
    for(int i=2;i<n;i++)
    {
        mine[i] = num[i-1] - mine[i-1] - mine[i-2];
        if(mine[i]!=0&&mine[i]!=1)
            return 0;
    }
    if(mine[n-1]+mine[n-2]!=num[n-1])
        return 0;
    return 1;
}

int main() {
    
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> num[i];
    if(n==1)
    {
        cout << 1 << endl;
        return 0;
    }
    int t = num[0];
    if(t==0)
    {
        // mine[0] = mine[1] = 0;
        cout << deduce() << endl;
    } else if(t==1)
    {
        mine[0] = 1;
        int tmp = deduce();
        mine[0] = 0;
        mine[1] = 1;
        cout << tmp + deduce() << endl;
    } else if(t==2)
    {
        mine[0] = mine[1] = 1;
        cout << deduce() << endl;
    }
}

标签:题目,格子,int,mine,MINE,NC20241,num,扫雷,SCOI2005
来源: https://www.cnblogs.com/zhangyi101/p/16448452.html