# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
332729 | 2020-12-03T04:51:03 Z | daniel920712 | JOIRIS (JOI16_joiris) | C++14 | 1 ms | 384 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <vector> using namespace std; int all[55]; bool ok2[55]={0}; vector < pair < int , int > > ans; int main() { int N,M,t=0,ok,small,i,j,st,ttt; scanf("%d %d",&N,&M); for(i=0;i<N;i++) { scanf("%d",&all[i]); t+=all[i]; //all[i]=i%2; } if(t%2!=N%2&&N%2==0) { printf("-1\n"); return 0; } else { while(1) { ttt=0; for(i=0;i<N;i++) ok2[i]=0; for(i=0;i<N;i++) { if(i+2<N&&all[i]==1&&all[i+1]==0&&all[i+2]==1) { ttt=1; ok2[i]=1; ok2[i+1]=1; ok2[i+2]=1; ans.push_back(make_pair(2,i+1)); all[i]++; all[i+1]++; ans.push_back(make_pair(1,i+3)); all[i+2]+=2; //break; } } if(ttt) { for(j=0;j<N;j++) { if(all[j]>=2||ok2[j]) continue; ans.push_back(make_pair(1,j+1)); all[j]+=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++) { 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 if(i+3<N&&all[i+1]==1&&all[i+2]==0&all[i+3]==1) { ans.push_back(make_pair(1,i+1)); all[i]+=2; ans.push_back(make_pair(2,i+2)); all[i+1]++; all[i+2]++; ans.push_back(make_pair(1,i+4)); all[i+3]+=2; } 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; } } printf("%d\n",ans.size()); for(auto i:ans) printf("%d %d\n",i.first,i.second); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 0 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 0 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Incorrect | 1 ms | 384 KB | Output isn't correct |
18 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 0 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 0 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 0 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 1 ms | 364 KB | Output is correct |
20 | Correct | 1 ms | 364 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 1 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 1 ms | 364 KB | Output is correct |
30 | Correct | 1 ms | 364 KB | Output is correct |
31 | Correct | 1 ms | 364 KB | Output is correct |
32 | Correct | 1 ms | 364 KB | Output is correct |
33 | Incorrect | 1 ms | 384 KB | Output isn't correct |
34 | Halted | 0 ms | 0 KB | - |