# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
45261 | ikura355 | DEL13 (info1cup18_del13) | C++14 | 8 ms | 1472 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |