QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#135860 | #5176. 多控制反转 | 1kri | 100 ✓ | 9ms | 3576kb | C++14 | 1.5kb | 2023-08-06 11:19:36 | 2023-08-06 11:19:39 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
int n,m,q,sub_id;
int tot,sta[1005][4];
int c[1005];
void add(int a,int b,int c,int d){
++tot;
sta[tot][0]=a,sta[tot][1]=b,sta[tot][2]=c,sta[tot][3]=d;
return;
}
void work(vector<int> a,vector<int> b,int o){
int la=(int)a.size(),lb=(int)b.size();
if (la==0){
if (o==1)add(1,b[0],-1,-1);
return;
}
if (la==1){
if (o==1)add(2,a[0],b[0],-1);
return;
}
if (la==2){
if (o==1)add(3,a[0],a[1],b[0]);
return;
}
if (o==1)add(3,a[0],b[1],b[0]);
vector<int> _a,_b;
for (int i=1;i<(int)a.size();i++)_a.push_back(a[i]),_b.push_back(b[i]);
work(_a,_b,1);
if (o==1)add(3,a[0],b[1],b[0]);
return;
}
int main(){
cin>>n>>m>>q>>sub_id;
if (n==0){
cout<<1<<endl;
cout<<"1 0"<<endl;
return 0;
}
if (n==1){
cout<<1<<endl;
cout<<"2 0 1"<<endl;
return 0;
}
if (n==2){
cout<<1<<endl;
cout<<"3 0 1 2"<<endl;
return 0;
}
vector<int> t0,t1;
int x=n,y=n+1;
for (int i=0;i<n/2;i++)t0.push_back(i);
for (int i=n/2;i<n;i++)t1.push_back(i);
vector<int> a,b;
a=t0,b=t1;
a.push_back(y),b.insert(b.begin(),x);
work(a,b,1);
work(a,b,0);
a=t1,b=t0;
b.insert(b.begin(),y);
work(a,b,1);
work(a,b,0);
a=t0,b=t1;
a.push_back(y),b.insert(b.begin(),x);
work(a,b,1);
work(a,b,0);
a=t1,b=t0;
b.insert(b.begin(),y);
work(a,b,1);
work(a,b,0);
cout<<tot<<endl;
for (int i=1;i<=tot;i++){
cout<<sta[i][0]<<' ';
for (int j=1;j<=sta[i][0];j++)cout<<sta[i][j]<<' ';
cout<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 1ms
memory: 3444kb
input:
0 2 1 1
output:
1 1 0
result:
ok OK.
Test #2:
score: 0
Accepted
time: 2ms
memory: 3516kb
input:
13 28 105 1
output:
80 3 0 6 13 3 1 7 6 3 2 8 7 3 3 9 8 3 4 10 9 3 5 14 10 3 4 10 9 3 3 9 8 3 2 8 7 3 1 7 6 3 0 6 13 3 1 7 6 3 2 8 7 3 3 9 8 3 4 10 9 3 5 14 10 3 4 10 9 3 3 9 8 3 2 8 7 3 1 7 6 3 6 0 14 3 7 1 0 3 8 2 1 3 9 3 2 3 10 4 3 3 11 12 4 3 10 4 3 3 9 3 2 3 8 2 1 3 7 1 0 3 6 0 14 3 ...
result:
ok OK.
Test #3:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
5 12 41 1
output:
16 3 0 2 5 3 1 6 2 3 0 2 5 3 1 6 2 3 2 0 6 3 3 4 0 3 2 0 6 3 3 4 0 3 0 2 5 3 1 6 2 3 0 2 5 3 1 6 2 3 2 0 6 3 3 4 0 3 2 0 6 3 3 4 0
result:
ok OK.
Test #4:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
20 42 161 1
output:
136 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17 16 3 6 16 15 3 5 15 14 3 4 14 13 3 3 13 12 3 2 12 11 3 1 11 10 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 ...
result:
ok OK.
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #5:
score: 10
Accepted
time: 4ms
memory: 3516kb
input:
48 98 385 2
output:
360 3 0 24 48 3 1 25 24 3 2 26 25 3 3 27 26 3 4 28 27 3 5 29 28 3 6 30 29 3 7 31 30 3 8 32 31 3 9 33 32 3 10 34 33 3 11 35 34 3 12 36 35 3 13 37 36 3 14 38 37 3 15 39 38 3 16 40 39 3 17 41 40 3 18 42 41 3 19 43 42 3 20 44 43 3 21 45 44 3 22 46 45 3 23 49 46 3 22 46 45 3 21 4...
result:
ok OK.
Test #6:
score: 0
Accepted
time: 4ms
memory: 3568kb
input:
41 84 329 2
output:
304 3 0 20 41 3 1 21 20 3 2 22 21 3 3 23 22 3 4 24 23 3 5 25 24 3 6 26 25 3 7 27 26 3 8 28 27 3 9 29 28 3 10 30 29 3 11 31 30 3 12 32 31 3 13 33 32 3 14 34 33 3 15 35 34 3 16 36 35 3 17 37 36 3 18 38 37 3 19 42 38 3 18 38 37 3 17 37 36 3 16 36 35 3 15 35 34 3 14 34 33 3 13 3...
result:
ok OK.
Test #7:
score: 0
Accepted
time: 5ms
memory: 3476kb
input:
50 102 401 2
output:
376 3 0 25 50 3 1 26 25 3 2 27 26 3 3 28 27 3 4 29 28 3 5 30 29 3 6 31 30 3 7 32 31 3 8 33 32 3 9 34 33 3 10 35 34 3 11 36 35 3 12 37 36 3 13 38 37 3 14 39 38 3 15 40 39 3 16 41 40 3 17 42 41 3 18 43 42 3 19 44 43 3 20 45 44 3 21 46 45 3 22 47 46 3 23 48 47 3 24 51 48 3 23 4...
result:
ok OK.
Subtask #3:
score: 10
Accepted
Dependency #2:
100%
Accepted
Test #8:
score: 10
Accepted
time: 1ms
memory: 3456kb
input:
0 2 1 3
output:
1 1 0
result:
ok OK.
Test #9:
score: 0
Accepted
time: 2ms
memory: 3564kb
input:
19 40 153 3
output:
128 3 0 9 19 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 20 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3 2 11 10 3 1 10 9 3 0 9 19 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 20 16 3 7 16 15 3 6 15 14 3 5 ...
result:
ok OK.
Test #10:
score: 0
Accepted
time: 4ms
memory: 3520kb
input:
47 96 377 3
output:
352 3 0 23 47 3 1 24 23 3 2 25 24 3 3 26 25 3 4 27 26 3 5 28 27 3 6 29 28 3 7 30 29 3 8 31 30 3 9 32 31 3 10 33 32 3 11 34 33 3 12 35 34 3 13 36 35 3 14 37 36 3 15 38 37 3 16 39 38 3 17 40 39 3 18 41 40 3 19 42 41 3 20 43 42 3 21 44 43 3 22 48 44 3 21 44 43 3 20 43 42 3 19 4...
result:
ok OK.
Test #11:
score: 0
Accepted
time: 1ms
memory: 3448kb
input:
25 52 201 3
output:
176 3 0 12 25 3 1 13 12 3 2 14 13 3 3 15 14 3 4 16 15 3 5 17 16 3 6 18 17 3 7 19 18 3 8 20 19 3 9 21 20 3 10 22 21 3 11 26 22 3 10 22 21 3 9 21 20 3 8 20 19 3 7 19 18 3 6 18 17 3 5 17 16 3 4 16 15 3 3 15 14 3 2 14 13 3 1 13 12 3 0 12 25 3 1 13 12 3 2 14 13 3 3 15 14 3 4 16 ...
result:
ok OK.
Test #12:
score: 0
Accepted
time: 2ms
memory: 3536kb
input:
50 102 401 3
output:
376 3 0 25 50 3 1 26 25 3 2 27 26 3 3 28 27 3 4 29 28 3 5 30 29 3 6 31 30 3 7 32 31 3 8 33 32 3 9 34 33 3 10 35 34 3 11 36 35 3 12 37 36 3 13 38 37 3 14 39 38 3 15 40 39 3 16 41 40 3 17 42 41 3 18 43 42 3 19 44 43 3 20 45 44 3 21 46 45 3 22 47 46 3 23 48 47 3 24 51 48 3 23 4...
result:
ok OK.
Subtask #4:
score: 10
Accepted
Test #13:
score: 10
Accepted
time: 1ms
memory: 3500kb
input:
0 2 1 4
output:
1 1 0
result:
ok OK.
Test #14:
score: 0
Accepted
time: 2ms
memory: 3512kb
input:
18 20 325 4
output:
120 3 0 9 18 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 19 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3 2 11 10 3 1 10 9 3 0 9 18 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 19 16 3 7 16 15 3 6 15 14 3 5 ...
result:
ok OK.
Test #15:
score: 0
Accepted
time: 2ms
memory: 3512kb
input:
14 16 197 4
output:
88 3 0 7 14 3 1 8 7 3 2 9 8 3 3 10 9 3 4 11 10 3 5 12 11 3 6 15 12 3 5 12 11 3 4 11 10 3 3 10 9 3 2 9 8 3 1 8 7 3 0 7 14 3 1 8 7 3 2 9 8 3 3 10 9 3 4 11 10 3 5 12 11 3 6 15 12 3 5 12 11 3 4 11 10 3 3 10 9 3 2 9 8 3 1 8 7 3 7 0 15 3 8 1 0 3 9 2 1 3 10 3 2 3 11 4 3 3 12 13...
result:
ok OK.
Test #16:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
20 22 401 4
output:
136 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17 16 3 6 16 15 3 5 15 14 3 4 14 13 3 3 13 12 3 2 12 11 3 1 11 10 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 ...
result:
ok OK.
Subtask #5:
score: 20
Accepted
Dependency #4:
100%
Accepted
Test #17:
score: 20
Accepted
time: 0ms
memory: 3456kb
input:
18 20 325 5
output:
120 3 0 9 18 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 19 16 3 7 16 15 3 6 15 14 3 5 14 13 3 4 13 12 3 3 12 11 3 2 11 10 3 1 10 9 3 0 9 18 3 1 10 9 3 2 11 10 3 3 12 11 3 4 13 12 3 5 14 13 3 6 15 14 3 7 16 15 3 8 19 16 3 7 16 15 3 6 15 14 3 5 ...
result:
ok OK.
Test #18:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
17 19 290 5
output:
112 3 0 8 17 3 1 9 8 3 2 10 9 3 3 11 10 3 4 12 11 3 5 13 12 3 6 14 13 3 7 18 14 3 6 14 13 3 5 13 12 3 4 12 11 3 3 11 10 3 2 10 9 3 1 9 8 3 0 8 17 3 1 9 8 3 2 10 9 3 3 11 10 3 4 12 11 3 5 13 12 3 6 14 13 3 7 18 14 3 6 14 13 3 5 13 12 3 4 12 11 3 3 11 10 3 2 10 9 3 1 9 8 3 ...
result:
ok OK.
Test #19:
score: 0
Accepted
time: 2ms
memory: 3480kb
input:
20 22 401 5
output:
136 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 3 9 21 18 3 8 18 17 3 7 17 16 3 6 16 15 3 5 15 14 3 4 14 13 3 3 13 12 3 2 12 11 3 1 11 10 3 0 10 20 3 1 11 10 3 2 12 11 3 3 13 12 3 4 14 13 3 5 15 14 3 6 16 15 3 7 17 16 3 8 18 17 ...
result:
ok OK.
Subtask #6:
score: 10
Accepted
Test #20:
score: 10
Accepted
time: 0ms
memory: 3460kb
input:
14 16 393 6
output:
88 3 0 7 14 3 1 8 7 3 2 9 8 3 3 10 9 3 4 11 10 3 5 12 11 3 6 15 12 3 5 12 11 3 4 11 10 3 3 10 9 3 2 9 8 3 1 8 7 3 0 7 14 3 1 8 7 3 2 9 8 3 3 10 9 3 4 11 10 3 5 12 11 3 6 15 12 3 5 12 11 3 4 11 10 3 3 10 9 3 2 9 8 3 1 8 7 3 7 0 15 3 8 1 0 3 9 2 1 3 10 3 2 3 11 4 3 3 12 13...
result:
ok OK.
Test #21:
score: 0
Accepted
time: 4ms
memory: 3460kb
input:
39 41 1093 6
output:
288 3 0 19 39 3 1 20 19 3 2 21 20 3 3 22 21 3 4 23 22 3 5 24 23 3 6 25 24 3 7 26 25 3 8 27 26 3 9 28 27 3 10 29 28 3 11 30 29 3 12 31 30 3 13 32 31 3 14 33 32 3 15 34 33 3 16 35 34 3 17 36 35 3 18 40 36 3 17 36 35 3 16 35 34 3 15 34 33 3 14 33 32 3 13 32 31 3 12 31 30 3 11 3...
result:
ok OK.
Test #22:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
0 2 1 6
output:
1 1 0
result:
ok OK.
Test #23:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
50 52 1401 6
output:
376 3 0 25 50 3 1 26 25 3 2 27 26 3 3 28 27 3 4 29 28 3 5 30 29 3 6 31 30 3 7 32 31 3 8 33 32 3 9 34 33 3 10 35 34 3 11 36 35 3 12 37 36 3 13 38 37 3 14 39 38 3 15 40 39 3 16 41 40 3 17 42 41 3 18 43 42 3 19 44 43 3 20 45 44 3 21 46 45 3 22 47 46 3 23 48 47 3 24 51 48 3 23 4...
result:
ok OK.
Subtask #7:
score: 10
Accepted
Dependency #2:
100%
Accepted
Dependency #4:
100%
Accepted
Test #24:
score: 10
Accepted
time: 9ms
memory: 3556kb
input:
93 95 745 7
output:
720 3 0 46 93 3 1 47 46 3 2 48 47 3 3 49 48 3 4 50 49 3 5 51 50 3 6 52 51 3 7 53 52 3 8 54 53 3 9 55 54 3 10 56 55 3 11 57 56 3 12 58 57 3 13 59 58 3 14 60 59 3 15 61 60 3 16 62 61 3 17 63 62 3 18 64 63 3 19 65 64 3 20 66 65 3 21 67 66 3 22 68 67 3 23 69 68 3 24 70 69 3 25 7...
result:
ok OK.
Test #25:
score: 0
Accepted
time: 6ms
memory: 3520kb
input:
82 84 657 7
output:
632 3 0 41 82 3 1 42 41 3 2 43 42 3 3 44 43 3 4 45 44 3 5 46 45 3 6 47 46 3 7 48 47 3 8 49 48 3 9 50 49 3 10 51 50 3 11 52 51 3 12 53 52 3 13 54 53 3 14 55 54 3 15 56 55 3 16 57 56 3 17 58 57 3 18 59 58 3 19 60 59 3 20 61 60 3 21 62 61 3 22 63 62 3 23 64 63 3 24 65 64 3 25 6...
result:
ok OK.
Test #26:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
100 102 801 7
output:
776 3 0 50 100 3 1 51 50 3 2 52 51 3 3 53 52 3 4 54 53 3 5 55 54 3 6 56 55 3 7 57 56 3 8 58 57 3 9 59 58 3 10 60 59 3 11 61 60 3 12 62 61 3 13 63 62 3 14 64 63 3 15 65 64 3 16 66 65 3 17 67 66 3 18 68 67 3 19 69 68 3 20 70 69 3 21 71 70 3 22 72 71 3 23 73 72 3 24 74 73 3 25 ...
result:
ok OK.
Subtask #8:
score: 15
Accepted
Dependency #3:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Dependency #7:
100%
Accepted
Test #27:
score: 15
Accepted
time: 1ms
memory: 3488kb
input:
94 96 753 8
output:
728 3 0 47 94 3 1 48 47 3 2 49 48 3 3 50 49 3 4 51 50 3 5 52 51 3 6 53 52 3 7 54 53 3 8 55 54 3 9 56 55 3 10 57 56 3 11 58 57 3 12 59 58 3 13 60 59 3 14 61 60 3 15 62 61 3 16 63 62 3 17 64 63 3 18 65 64 3 19 66 65 3 20 67 66 3 21 68 67 3 22 69 68 3 23 70 69 3 24 71 70 3 25 7...
result:
ok OK.
Test #28:
score: 0
Accepted
time: 3ms
memory: 3528kb
input:
70 72 561 8
output:
536 3 0 35 70 3 1 36 35 3 2 37 36 3 3 38 37 3 4 39 38 3 5 40 39 3 6 41 40 3 7 42 41 3 8 43 42 3 9 44 43 3 10 45 44 3 11 46 45 3 12 47 46 3 13 48 47 3 14 49 48 3 15 50 49 3 16 51 50 3 17 52 51 3 18 53 52 3 19 54 53 3 20 55 54 3 21 56 55 3 22 57 56 3 23 58 57 3 24 59 58 3 25 6...
result:
ok OK.
Test #29:
score: 0
Accepted
time: 4ms
memory: 3492kb
input:
100 102 801 8
output:
776 3 0 50 100 3 1 51 50 3 2 52 51 3 3 53 52 3 4 54 53 3 5 55 54 3 6 56 55 3 7 57 56 3 8 58 57 3 9 59 58 3 10 60 59 3 11 61 60 3 12 62 61 3 13 63 62 3 14 64 63 3 15 65 64 3 16 66 65 3 17 67 66 3 18 68 67 3 19 69 68 3 20 70 69 3 21 71 70 3 22 72 71 3 23 73 72 3 24 74 73 3 25 ...
result:
ok OK.
Extra Test:
score: 0
Extra Test Passed