Submission #45261

# Submission time Handle Problem Language Result Execution time Memory
45261 2018-04-12T09:28:35 Z ikura355 DEL13 (info1cup18_del13) C++14
0 / 100
8 ms 1472 KB
#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");
    }
}

Compilation message

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 time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 3 ms 500 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 3 ms 500 KB Output isn't correct
3 Incorrect 8 ms 500 KB Output isn't correct
4 Incorrect 6 ms 688 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 696 KB Output isn't correct
2 Execution timed out 3 ms 876 KB Time limit exceeded (wall clock)
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 3 ms 500 KB Output isn't correct
3 Incorrect 8 ms 500 KB Output isn't correct
4 Incorrect 6 ms 688 KB Output isn't correct
5 Incorrect 3 ms 876 KB Output isn't correct
6 Incorrect 3 ms 888 KB Output isn't correct
7 Incorrect 2 ms 900 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 3 ms 500 KB Output isn't correct
3 Incorrect 8 ms 500 KB Output isn't correct
4 Incorrect 6 ms 688 KB Output isn't correct
5 Incorrect 3 ms 876 KB Output isn't correct
6 Incorrect 3 ms 888 KB Output isn't correct
7 Incorrect 2 ms 900 KB Output isn't correct
8 Execution timed out 3 ms 956 KB Time limit exceeded (wall clock)
9 Execution timed out 3 ms 1192 KB Time limit exceeded (wall clock)
10 Execution timed out 4 ms 1232 KB Time limit exceeded (wall clock)
11 Execution timed out 3 ms 1472 KB Time limit exceeded (wall clock)