답안 #30698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
30698 2017-07-26T07:01:35 Z okaybody10 볼질 (OJUZ10_ballparade) C++
100 / 100
9 ms 1116 KB
#include <stdio.h>
#include <memory.h>

int main()
{
    int N;
    scanf("%d",&N);
    bool base[5];
    memset(base,0,sizeof(base));
    int ballcnt=0,error=0;
    for(int i=0;i<N;i++)
    {
        int throwb;
        scanf("%d",&throwb);
        if(throwb==1)
        {
            ballcnt+=1;
            if(ballcnt==4)
            {
            if(base[1] && base[2] && base[3])
            {
                base[3]=false;
                error+=1;
            }
            if(base[1] && base[2])
            {
                base[3]=true;
            }
            if(base[1])
                base[2]=true;
            base[1]=true;
            ballcnt=0;
        }
        }
        else if(throwb==2)
        {
            if(base[1] && base[2] && base[3])
            {
                base[3]=false;
                error+=1;
            }
            if(base[1] && base[2])
            {
                base[3]=true;
            }
            if(base[1])
                base[2]=true;
            base[1]=true;
            ballcnt=0;
        }
        else
        {
            ballcnt+=1;
            if(base[3])
            {
                base[3]=false;
                error+=1;
            }
            if(base[2])
            {
                base[3]=true;
                base[2]=false;
            }
            if(base[1])
            {
                base[1]=false;
                base[2]=true;
            }
            if(ballcnt==4)
            {
                base[1]=true;
                ballcnt=0;
            }
        }
    }
    printf("%d",error);
}

Compilation message

ballparade.cpp: In function 'int main()':
ballparade.cpp:7:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
                   ^
ballparade.cpp:14:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&throwb);
                            ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 3 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 6 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 6 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 0 ms 1116 KB Output is correct
8 Correct 3 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 9 ms 1116 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
6 Correct 0 ms 1116 KB Output is correct
7 Correct 6 ms 1116 KB Output is correct
8 Correct 0 ms 1116 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 3 ms 1116 KB Output is correct
11 Correct 0 ms 1116 KB Output is correct
12 Correct 6 ms 1116 KB Output is correct
13 Correct 9 ms 1116 KB Output is correct
14 Correct 6 ms 1116 KB Output is correct
15 Correct 6 ms 1116 KB Output is correct