⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 saratov239.cpp

📁 My solutions to Saratov Online Judge Problems(SGU), not all, but many of them...
💻 CPP
字号:
/*
Alfonso2 Peterssen
15 - 5 - 2008
Saratov #239 "Minesweeper"
*/
#include <cstdio>

const int MAXN = 2000;

int N, i, sol;
int last, cent, next;
int mines[MAXN];

int main() {

    scanf( "%d", &N );
    for ( i = 1; i <= N; i++ )
        scanf( "%d", &mines[i] );

    last = cent = next = 0;
    cent = 0;
    for ( i = 1; i <= N; i++ ) {
        next = mines[i] - cent - last;
        if ( next < 0 || next > 1 ) // Ooops
            break;
        last = cent;
        cent = next;
    }

    if ( i > N && next == 0 )
        sol++;

    last = cent = next = 0;
    cent = 1;
    for ( i = 1; i <= N; i++ ) {
        next = mines[i] - cent - last;
        if ( next < 0 || next > 1 ) // Ooops
            break;
        last = cent;
        cent = next;
    }

    if ( i > N && next == 0 )
        sol++;

    printf( "%d\n", sol );

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -