제출 #45261

#제출 시각아이디문제언어결과실행 시간메모리
45261ikura355DEL13 (info1cup18_del13)C++14
0 / 100
8 ms1472 KiB
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 5;
int n,k;
int a[maxn];
int main() {
    int T;
    scanf("%d",&T);
    while(T--) {
        scanf("%d%d",&n,&k);
        for(int i=1;i<=k;i++) scanf("%d",&a[i]);
        a[0] = 0; a[k+1] = n+1;
        int last = 0, bad = 0;
//        printf("\t\t");
        for(int i=1;i<=k+1;i++) {
            int t = a[i]-a[i-1]-1;
//            printf("%d ",t);
            if(last==0) {
                if(t%2==0) {
                    if(t==0) last = 0;
                    else if(t>=2) last = 2;
                }
                else {
                    if(t==1) last = 1;
                    else if(t>=3) last = 1;
                }
            }
            else if(last==1) {
                if(t%2==0) {
                    if(t==0) bad = 1;
                    else if(t>=2) last = 1;
                }
                else last = 0;
            }
            else if(last==2) {
                if(t%2==0) {
                    if(t==0) bad = 1;
                    else if(t>=2) last = 0;
                }
                else {
                    if(t==1) bad = 1;
                    else if(t>=3) last = 1;
                }
            }
            if(bad) break;
        }
//        printf("\n");
        if(bad) printf("-1\n");
        else printf("0\n");
    }
}

컴파일 시 표준 에러 (stderr) 메시지

del13.cpp: In function 'int main()':
del13.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&T);
     ~~~~~^~~~~~~~~
del13.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&n,&k);
         ~~~~~^~~~~~~~~~~~~~
del13.cpp:11:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for(int i=1;i<=k;i++) scanf("%d",&a[i]);
                               ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...