# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
332683 | 2020-12-03T02:57:18 Z | daniel920712 | JOIRIS (JOI16_joiris) | C++14 | 499 ms | 262148 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <vector> using namespace std; int all[55]; vector < pair < int , int > > ans; int main() { int N,M,t=0,ok,small,i; scanf("%d %d",&N,&M); for(i=0;i<N;i++) { scanf("%d",&all[i]); t+=all[i]; } if(t%2==1) { printf("-1\n"); return 0; } else { while(1) { ok=1; for(i=0;i<N;i+=2) if(all[i]==1||all[i+1]==0) ok=0; if(ok) { ans.push_back(make_pair(2,1)); for(i=2;i<N;i++) ans.push_back(make_pair(1,i+1)); ans.push_back(make_pair(1,1)); all[0]=0; all[1]=1; all[2]=1; for(i=3;i<N;i++) all[i]=i%2+1; } else { for(i=0;i<N;i++) { if(all[i]==0) { if(i+1<N&&all[i+1]==0) { ans.push_back(make_pair(2,i+1)); all[i]++; all[i+1]++; } else { ans.push_back(make_pair(1,i+1)); all[i]+=2; } } } small=all[0]; for(i=0;i<N;i++) small=min(small,all[i]); for(i=0;i<N;i++) all[i]-=small; for(i=0;i<N;i++) if(all[i]) break; if(i==N) break; } /*for(i=0;i<N;i++) printf("%d ",all[i]); printf("\n");*/ } } printf("%d\n",ans.size()); for(auto i:ans) printf("%d %d\n",i.first,i.second); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Runtime error | 499 ms | 262148 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Runtime error | 499 ms | 262148 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Runtime error | 499 ms | 262148 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
8 | Halted | 0 ms | 0 KB | - |