Submission #18026

# Submission time Handle Problem Language Result Execution time Memory
18026 2016-01-18T12:39:19 Z gs14004 동전 게임 (KOI15_coin) C++14
100 / 100
42 ms 5524 KB
#include <cstdio>
#include <queue>
using namespace std;
 
int k, q;
int vis[1005][1005];
 
queue<int> qx, qy;
 
int main(){
    scanf("%d %d",&k,&q);
    qx.push(0);
    qy.push(0);
    vis[0][0] = 1;
    while(!qx.empty()){
        int xf = qx.front();
        int yf = qy.front();
        qx.pop(), qy.pop();
        if(yf + 1 <= k && !vis[xf][yf+1]){
            int p = k - yf;
            // xf should add these
            if(xf + p < yf + 1) continue;
            vis[xf][yf+1] = 1;
            qx.push(xf);
            qy.push(yf+1);
        }
        if(xf +1 <= k && !vis[xf+1][yf]){
            int p = k - xf;
            if(yf + p + 1 < xf + 1) continue;
            qx.push(xf+1);
            qy.push(yf);
            vis[xf+1][yf] = 1;
        }
        if(xf+1<=k && yf+1<=k && !vis[xf+1][yf+1]){
            qx.push(xf+1);
            qy.push(yf+1);
            vis[xf+1][yf+1] = 1;
        }
    }
    while(q--){
        int a, b;
        scanf("%d %d",&a,&b);
        printf("%d\n",vis[a][b]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5524 KB Output is correct
2 Correct 0 ms 5524 KB Output is correct
3 Correct 0 ms 5524 KB Output is correct
4 Correct 0 ms 5524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5524 KB Output is correct
2 Correct 0 ms 5524 KB Output is correct
3 Correct 0 ms 5524 KB Output is correct
4 Correct 0 ms 5524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5524 KB Output is correct
2 Correct 0 ms 5524 KB Output is correct
3 Correct 3 ms 5524 KB Output is correct
4 Correct 34 ms 5524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 5524 KB Output is correct
2 Correct 1 ms 5524 KB Output is correct
3 Correct 23 ms 5524 KB Output is correct
4 Correct 30 ms 5524 KB Output is correct
5 Correct 42 ms 5524 KB Output is correct
6 Correct 42 ms 5524 KB Output is correct
7 Correct 20 ms 5524 KB Output is correct
8 Correct 22 ms 5524 KB Output is correct