답안 #19266

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19266 2016-02-23T15:17:07 Z ansol1111 동전 게임 (KOI15_coin) C++
100 / 100
38 ms 6980 KB
#include<stdio.h>

int k, n, check[1005][1005], p[100005][5];

int input()
{
    int i;

    scanf("%d",&k);
    scanf("%d",&n);
    for(i=1 ; i<=n ; i++)
    {
        scanf("%d %d",&p[i][1],&p[i][2]);
    }

    return 0;
}

int process()
{
    int i, j, num=0, num1=0, num2=0;

    for(i=0 ; i<=k ; i++)
    {
        check[i][i]=1;
        if((i-1)>=0)
        {
            check[i-1][i]=1, check[i][i-1]=1;
        }
        if((i+1)<=k)
        {
            check[i][i+1]=1, check[i+1][i]=1;
        }
        for(j=1 ; j<=k-i ; j++)
        {
            num=i+j, num1=k-j-1;
            if(num<=num1) check[num][i-1]=1;
            else break;
        }
        if(num!=0) check[num][i-1]=1;

        num=0, num1=0;
        num=k-(i+1);
        num1=num/2;
        for(j=1 ; j<=num1 ; j++)
        {
            num2=i+1+j;
            check[i][num2]=1;
        }
        num=0;
        num1=0;
        num2=0;
    }

    return 0;
}

int output()
{
    int i, y=0, x=0;

    for(i=1 ; i<=n ; i++)
    {
        y=p[i][1], x=p[i][2];
        printf("%d\n",check[y][x]);
    }

    return 0;
}

int main()
{
    input();
    process();
    output();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6980 KB Output is correct
2 Correct 0 ms 6980 KB Output is correct
3 Correct 0 ms 6980 KB Output is correct
4 Correct 0 ms 6980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6980 KB Output is correct
2 Correct 0 ms 6980 KB Output is correct
3 Correct 0 ms 6980 KB Output is correct
4 Correct 0 ms 6980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6980 KB Output is correct
2 Correct 0 ms 6980 KB Output is correct
3 Correct 0 ms 6980 KB Output is correct
4 Correct 28 ms 6980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6980 KB Output is correct
2 Correct 2 ms 6980 KB Output is correct
3 Correct 17 ms 6980 KB Output is correct
4 Correct 22 ms 6980 KB Output is correct
5 Correct 33 ms 6980 KB Output is correct
6 Correct 30 ms 6980 KB Output is correct
7 Correct 27 ms 6980 KB Output is correct
8 Correct 38 ms 6980 KB Output is correct