QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#72554 | #5176. 多控制反转 | zhouhuanyi | 100 ✓ | 3ms | 3704kb | C++14 | 1.8kb | 2023-01-16 14:29:58 | 2023-01-16 14:30:32 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
#include<cassert>
#define N 100000
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
struct reads
{
int op,x,y,z;
};
reads tong[N+1];
int n,m,sq,c,length;
vector<int>F(vector<int>p,int d)
{
p.push_back(d);
return p;
}
void solve(vector<int>p,vector<int>q,int d)
{
if (p.empty()) tong[++length]=(reads){1,d};
else if (p.size()==1) tong[++length]=(reads){2,p[0],d};
else if (p.size()==2) tong[++length]=(reads){3,p[0],p[1],d};
else
{
int l=length+1,r;
tong[++length]=(reads){2,q[(int)(p.size())-2],d};
for (int i=p.size()-1;i>=2;--i) tong[++length]=(reads){3,p[i],q[i-2],q[i-1]};
tong[++length]=(reads){3,p[0],p[1],q[0]};
for (int i=2;i<=p.size()-1;++i) tong[++length]=(reads){3,p[i],q[i-2],q[i-1]};
tong[++length]=(reads){2,q[(int)(p.size())-2],d},r=length;
for (int i=r;i>=l;--i)
if (tong[i].y!=d)
tong[++length]=tong[i];
}
return;
}
int main()
{
vector<int>A;
vector<int>B;
n=read(),m=read(),sq=read(),c=read();
if (!n) tong[++length]=(reads){1,0};
else if (n==1) tong[++length]=(reads){2,0,1};
else if (n==2) tong[++length]=(reads){3,0,1,2};
else
{
for (int i=0;i<((n+1)>>1);++i) A.push_back(i);
for (int i=((n+1)>>1);i<=n-1;++i) B.push_back(i);
solve(A,F(B,n),n+1),solve(F(B,n+1),A,n),solve(A,F(B,n),n+1),solve(F(B,n+1),A,n);
}
printf("%d\n",length);
for (int i=1;i<=length;++i)
{
if (tong[i].op==1) printf("1 %d\n",tong[i].x);
else if (tong[i].op==2) printf("2 %d %d\n",tong[i].x,tong[i].y);
else printf("3 %d %d %d\n",tong[i].x,tong[i].y,tong[i].z);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 15
Accepted
Test #1:
score: 15
Accepted
time: 2ms
memory: 3676kb
input:
0 2 1 1
output:
1 1 0
result:
ok OK.
Test #2:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
13 28 105 1
output:
96 2 12 14 3 6 11 12 3 5 10 11 3 4 9 10 3 3 8 9 3 2 7 8 3 0 1 7 3 2 7 8 3 3 8 9 3 4 9 10 3 5 10 11 3 6 11 12 2 12 14 3 6 11 12 3 5 10 11 3 4 9 10 3 3 8 9 3 2 7 8 3 0 1 7 3 2 7 8 3 3 8 9 3 4 9 10 3 5 10 11 3 6 11 12 2 5 13 3 14 4 5 3 12 3 4 3 11 2 3 3 10 1 2 3 9 0 1 3 7 8 0 3 9 0 1 3 10 1 2 3 11 2 3 ...
result:
ok OK.
Test #3:
score: 0
Accepted
time: 2ms
memory: 3616kb
input:
5 12 41 1
output:
32 2 4 6 3 2 3 4 3 0 1 3 3 2 3 4 2 4 6 3 2 3 4 3 0 1 3 3 2 3 4 2 1 5 3 6 0 1 3 3 4 0 3 6 0 1 2 1 5 3 6 0 1 3 3 4 0 3 6 0 1 2 4 6 3 2 3 4 3 0 1 3 3 2 3 4 2 4 6 3 2 3 4 3 0 1 3 3 2 3 4 2 1 5 3 6 0 1 3 3 4 0 3 6 0 1 2 1 5 3 6 0 1 3 3 4 0 3 6 0 1
result:
ok OK.
Test #4:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
20 42 161 1
output:
152 2 18 21 3 9 17 18 3 8 16 17 3 7 15 16 3 6 14 15 3 5 13 14 3 4 12 13 3 3 11 12 3 2 10 11 3 0 1 10 3 2 10 11 3 3 11 12 3 4 12 13 3 5 13 14 3 6 14 15 3 7 15 16 3 8 16 17 3 9 17 18 2 18 21 3 9 17 18 3 8 16 17 3 7 15 16 3 6 14 15 3 5 13 14 3 4 12 13 3 3 11 12 3 2 10 11 3 0 1 10 3 2 10 11 3 3 11 12 3 ...
result:
ok OK.
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #5:
score: 10
Accepted
time: 2ms
memory: 3628kb
input:
48 98 385 2
output:
376 2 46 49 3 23 45 46 3 22 44 45 3 21 43 44 3 20 42 43 3 19 41 42 3 18 40 41 3 17 39 40 3 16 38 39 3 15 37 38 3 14 36 37 3 13 35 36 3 12 34 35 3 11 33 34 3 10 32 33 3 9 31 32 3 8 30 31 3 7 29 30 3 6 28 29 3 5 27 28 3 4 26 27 3 3 25 26 3 2 24 25 3 0 1 24 3 2 24 25 3 3 25 26 3 4 26 27 3 5 27 28 3 6 2...
result:
ok OK.
Test #6:
score: 0
Accepted
time: 2ms
memory: 3604kb
input:
41 84 329 2
output:
320 2 40 42 3 20 39 40 3 19 38 39 3 18 37 38 3 17 36 37 3 16 35 36 3 15 34 35 3 14 33 34 3 13 32 33 3 12 31 32 3 11 30 31 3 10 29 30 3 9 28 29 3 8 27 28 3 7 26 27 3 6 25 26 3 5 24 25 3 4 23 24 3 3 22 23 3 2 21 22 3 0 1 21 3 2 21 22 3 3 22 23 3 4 23 24 3 5 24 25 3 6 25 26 3 7 26 27 3 8 27 28 3 9 28 2...
result:
ok OK.
Test #7:
score: 0
Accepted
time: 2ms
memory: 3588kb
input:
50 102 401 2
output:
392 2 48 51 3 24 47 48 3 23 46 47 3 22 45 46 3 21 44 45 3 20 43 44 3 19 42 43 3 18 41 42 3 17 40 41 3 16 39 40 3 15 38 39 3 14 37 38 3 13 36 37 3 12 35 36 3 11 34 35 3 10 33 34 3 9 32 33 3 8 31 32 3 7 30 31 3 6 29 30 3 5 28 29 3 4 27 28 3 3 26 27 3 2 25 26 3 0 1 25 3 2 25 26 3 3 26 27 3 4 27 28 3 5 ...
result:
ok OK.
Subtask #3:
score: 10
Accepted
Dependency #2:
100%
Accepted
Test #8:
score: 10
Accepted
time: 0ms
memory: 3604kb
input:
0 2 1 3
output:
1 1 0
result:
ok OK.
Test #9:
score: 0
Accepted
time: 2ms
memory: 3588kb
input:
19 40 153 3
output:
144 2 18 20 3 9 17 18 3 8 16 17 3 7 15 16 3 6 14 15 3 5 13 14 3 4 12 13 3 3 11 12 3 2 10 11 3 0 1 10 3 2 10 11 3 3 11 12 3 4 12 13 3 5 13 14 3 6 14 15 3 7 15 16 3 8 16 17 3 9 17 18 2 18 20 3 9 17 18 3 8 16 17 3 7 15 16 3 6 14 15 3 5 13 14 3 4 12 13 3 3 11 12 3 2 10 11 3 0 1 10 3 2 10 11 3 3 11 12 3 ...
result:
ok OK.
Test #10:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
47 96 377 3
output:
368 2 46 48 3 23 45 46 3 22 44 45 3 21 43 44 3 20 42 43 3 19 41 42 3 18 40 41 3 17 39 40 3 16 38 39 3 15 37 38 3 14 36 37 3 13 35 36 3 12 34 35 3 11 33 34 3 10 32 33 3 9 31 32 3 8 30 31 3 7 29 30 3 6 28 29 3 5 27 28 3 4 26 27 3 3 25 26 3 2 24 25 3 0 1 24 3 2 24 25 3 3 25 26 3 4 26 27 3 5 27 28 3 6 2...
result:
ok OK.
Test #11:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
25 52 201 3
output:
192 2 24 26 3 12 23 24 3 11 22 23 3 10 21 22 3 9 20 21 3 8 19 20 3 7 18 19 3 6 17 18 3 5 16 17 3 4 15 16 3 3 14 15 3 2 13 14 3 0 1 13 3 2 13 14 3 3 14 15 3 4 15 16 3 5 16 17 3 6 17 18 3 7 18 19 3 8 19 20 3 9 20 21 3 10 21 22 3 11 22 23 3 12 23 24 2 24 26 3 12 23 24 3 11 22 23 3 10 21 22 3 9 20 21 3 ...
result:
ok OK.
Test #12:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
50 102 401 3
output:
392 2 48 51 3 24 47 48 3 23 46 47 3 22 45 46 3 21 44 45 3 20 43 44 3 19 42 43 3 18 41 42 3 17 40 41 3 16 39 40 3 15 38 39 3 14 37 38 3 13 36 37 3 12 35 36 3 11 34 35 3 10 33 34 3 9 32 33 3 8 31 32 3 7 30 31 3 6 29 30 3 5 28 29 3 4 27 28 3 3 26 27 3 2 25 26 3 0 1 25 3 2 25 26 3 3 26 27 3 4 27 28 3 5 ...
result:
ok OK.
Subtask #4:
score: 10
Accepted
Test #13:
score: 10
Accepted
time: 1ms
memory: 3676kb
input:
0 2 1 4
output:
1 1 0
result:
ok OK.
Test #14:
score: 0
Accepted
time: 2ms
memory: 3532kb
input:
18 20 325 4
output:
136 2 16 19 3 8 15 16 3 7 14 15 3 6 13 14 3 5 12 13 3 4 11 12 3 3 10 11 3 2 9 10 3 0 1 9 3 2 9 10 3 3 10 11 3 4 11 12 3 5 12 13 3 6 13 14 3 7 14 15 3 8 15 16 2 16 19 3 8 15 16 3 7 14 15 3 6 13 14 3 5 12 13 3 4 11 12 3 3 10 11 3 2 9 10 3 0 1 9 3 2 9 10 3 3 10 11 3 4 11 12 3 5 12 13 3 6 13 14 3 7 14 1...
result:
ok OK.
Test #15:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
14 16 197 4
output:
104 2 12 15 3 6 11 12 3 5 10 11 3 4 9 10 3 3 8 9 3 2 7 8 3 0 1 7 3 2 7 8 3 3 8 9 3 4 9 10 3 5 10 11 3 6 11 12 2 12 15 3 6 11 12 3 5 10 11 3 4 9 10 3 3 8 9 3 2 7 8 3 0 1 7 3 2 7 8 3 3 8 9 3 4 9 10 3 5 10 11 3 6 11 12 2 6 14 3 15 5 6 3 13 4 5 3 12 3 4 3 11 2 3 3 10 1 2 3 9 0 1 3 7 8 0 3 9 0 1 3 10 1 2...
result:
ok OK.
Test #16:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
20 22 401 4
output:
152 2 18 21 3 9 17 18 3 8 16 17 3 7 15 16 3 6 14 15 3 5 13 14 3 4 12 13 3 3 11 12 3 2 10 11 3 0 1 10 3 2 10 11 3 3 11 12 3 4 12 13 3 5 13 14 3 6 14 15 3 7 15 16 3 8 16 17 3 9 17 18 2 18 21 3 9 17 18 3 8 16 17 3 7 15 16 3 6 14 15 3 5 13 14 3 4 12 13 3 3 11 12 3 2 10 11 3 0 1 10 3 2 10 11 3 3 11 12 3 ...
result:
ok OK.
Subtask #5:
score: 20
Accepted
Dependency #4:
100%
Accepted
Test #17:
score: 20
Accepted
time: 2ms
memory: 3620kb
input:
18 20 325 5
output:
136 2 16 19 3 8 15 16 3 7 14 15 3 6 13 14 3 5 12 13 3 4 11 12 3 3 10 11 3 2 9 10 3 0 1 9 3 2 9 10 3 3 10 11 3 4 11 12 3 5 12 13 3 6 13 14 3 7 14 15 3 8 15 16 2 16 19 3 8 15 16 3 7 14 15 3 6 13 14 3 5 12 13 3 4 11 12 3 3 10 11 3 2 9 10 3 0 1 9 3 2 9 10 3 3 10 11 3 4 11 12 3 5 12 13 3 6 13 14 3 7 14 1...
result:
ok OK.
Test #18:
score: 0
Accepted
time: 2ms
memory: 3612kb
input:
17 19 290 5
output:
128 2 16 18 3 8 15 16 3 7 14 15 3 6 13 14 3 5 12 13 3 4 11 12 3 3 10 11 3 2 9 10 3 0 1 9 3 2 9 10 3 3 10 11 3 4 11 12 3 5 12 13 3 6 13 14 3 7 14 15 3 8 15 16 2 16 18 3 8 15 16 3 7 14 15 3 6 13 14 3 5 12 13 3 4 11 12 3 3 10 11 3 2 9 10 3 0 1 9 3 2 9 10 3 3 10 11 3 4 11 12 3 5 12 13 3 6 13 14 3 7 14 1...
result:
ok OK.
Test #19:
score: 0
Accepted
time: 2ms
memory: 3616kb
input:
20 22 401 5
output:
152 2 18 21 3 9 17 18 3 8 16 17 3 7 15 16 3 6 14 15 3 5 13 14 3 4 12 13 3 3 11 12 3 2 10 11 3 0 1 10 3 2 10 11 3 3 11 12 3 4 12 13 3 5 13 14 3 6 14 15 3 7 15 16 3 8 16 17 3 9 17 18 2 18 21 3 9 17 18 3 8 16 17 3 7 15 16 3 6 14 15 3 5 13 14 3 4 12 13 3 3 11 12 3 2 10 11 3 0 1 10 3 2 10 11 3 3 11 12 3 ...
result:
ok OK.
Subtask #6:
score: 10
Accepted
Test #20:
score: 10
Accepted
time: 1ms
memory: 3584kb
input:
14 16 393 6
output:
104 2 12 15 3 6 11 12 3 5 10 11 3 4 9 10 3 3 8 9 3 2 7 8 3 0 1 7 3 2 7 8 3 3 8 9 3 4 9 10 3 5 10 11 3 6 11 12 2 12 15 3 6 11 12 3 5 10 11 3 4 9 10 3 3 8 9 3 2 7 8 3 0 1 7 3 2 7 8 3 3 8 9 3 4 9 10 3 5 10 11 3 6 11 12 2 6 14 3 15 5 6 3 13 4 5 3 12 3 4 3 11 2 3 3 10 1 2 3 9 0 1 3 7 8 0 3 9 0 1 3 10 1 2...
result:
ok OK.
Test #21:
score: 0
Accepted
time: 3ms
memory: 3644kb
input:
39 41 1093 6
output:
304 2 38 40 3 19 37 38 3 18 36 37 3 17 35 36 3 16 34 35 3 15 33 34 3 14 32 33 3 13 31 32 3 12 30 31 3 11 29 30 3 10 28 29 3 9 27 28 3 8 26 27 3 7 25 26 3 6 24 25 3 5 23 24 3 4 22 23 3 3 21 22 3 2 20 21 3 0 1 20 3 2 20 21 3 3 21 22 3 4 22 23 3 5 23 24 3 6 24 25 3 7 25 26 3 8 26 27 3 9 27 28 3 10 28 2...
result:
ok OK.
Test #22:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
0 2 1 6
output:
1 1 0
result:
ok OK.
Test #23:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
50 52 1401 6
output:
392 2 48 51 3 24 47 48 3 23 46 47 3 22 45 46 3 21 44 45 3 20 43 44 3 19 42 43 3 18 41 42 3 17 40 41 3 16 39 40 3 15 38 39 3 14 37 38 3 13 36 37 3 12 35 36 3 11 34 35 3 10 33 34 3 9 32 33 3 8 31 32 3 7 30 31 3 6 29 30 3 5 28 29 3 4 27 28 3 3 26 27 3 2 25 26 3 0 1 25 3 2 25 26 3 3 26 27 3 4 27 28 3 5 ...
result:
ok OK.
Subtask #7:
score: 10
Accepted
Dependency #2:
100%
Accepted
Dependency #4:
100%
Accepted
Test #24:
score: 10
Accepted
time: 1ms
memory: 3620kb
input:
93 95 745 7
output:
736 2 92 94 3 46 91 92 3 45 90 91 3 44 89 90 3 43 88 89 3 42 87 88 3 41 86 87 3 40 85 86 3 39 84 85 3 38 83 84 3 37 82 83 3 36 81 82 3 35 80 81 3 34 79 80 3 33 78 79 3 32 77 78 3 31 76 77 3 30 75 76 3 29 74 75 3 28 73 74 3 27 72 73 3 26 71 72 3 25 70 71 3 24 69 70 3 23 68 69 3 22 67 68 3 21 66 67 3 ...
result:
ok OK.
Test #25:
score: 0
Accepted
time: 2ms
memory: 3628kb
input:
82 84 657 7
output:
648 2 80 83 3 40 79 80 3 39 78 79 3 38 77 78 3 37 76 77 3 36 75 76 3 35 74 75 3 34 73 74 3 33 72 73 3 32 71 72 3 31 70 71 3 30 69 70 3 29 68 69 3 28 67 68 3 27 66 67 3 26 65 66 3 25 64 65 3 24 63 64 3 23 62 63 3 22 61 62 3 21 60 61 3 20 59 60 3 19 58 59 3 18 57 58 3 17 56 57 3 16 55 56 3 15 54 55 3 ...
result:
ok OK.
Test #26:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
100 102 801 7
output:
792 2 98 101 3 49 97 98 3 48 96 97 3 47 95 96 3 46 94 95 3 45 93 94 3 44 92 93 3 43 91 92 3 42 90 91 3 41 89 90 3 40 88 89 3 39 87 88 3 38 86 87 3 37 85 86 3 36 84 85 3 35 83 84 3 34 82 83 3 33 81 82 3 32 80 81 3 31 79 80 3 30 78 79 3 29 77 78 3 28 76 77 3 27 75 76 3 26 74 75 3 25 73 74 3 24 72 73 3...
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: 2ms
memory: 3624kb
input:
94 96 753 8
output:
744 2 92 95 3 46 91 92 3 45 90 91 3 44 89 90 3 43 88 89 3 42 87 88 3 41 86 87 3 40 85 86 3 39 84 85 3 38 83 84 3 37 82 83 3 36 81 82 3 35 80 81 3 34 79 80 3 33 78 79 3 32 77 78 3 31 76 77 3 30 75 76 3 29 74 75 3 28 73 74 3 27 72 73 3 26 71 72 3 25 70 71 3 24 69 70 3 23 68 69 3 22 67 68 3 21 66 67 3 ...
result:
ok OK.
Test #28:
score: 0
Accepted
time: 2ms
memory: 3564kb
input:
70 72 561 8
output:
552 2 68 71 3 34 67 68 3 33 66 67 3 32 65 66 3 31 64 65 3 30 63 64 3 29 62 63 3 28 61 62 3 27 60 61 3 26 59 60 3 25 58 59 3 24 57 58 3 23 56 57 3 22 55 56 3 21 54 55 3 20 53 54 3 19 52 53 3 18 51 52 3 17 50 51 3 16 49 50 3 15 48 49 3 14 47 48 3 13 46 47 3 12 45 46 3 11 44 45 3 10 43 44 3 9 42 43 3 8...
result:
ok OK.
Test #29:
score: 0
Accepted
time: 2ms
memory: 3612kb
input:
100 102 801 8
output:
792 2 98 101 3 49 97 98 3 48 96 97 3 47 95 96 3 46 94 95 3 45 93 94 3 44 92 93 3 43 91 92 3 42 90 91 3 41 89 90 3 40 88 89 3 39 87 88 3 38 86 87 3 37 85 86 3 36 84 85 3 35 83 84 3 34 82 83 3 33 81 82 3 32 80 81 3 31 79 80 3 30 78 79 3 29 77 78 3 28 76 77 3 27 75 76 3 26 74 75 3 25 73 74 3 24 72 73 3...
result:
ok OK.
Extra Test:
score: 0
Extra Test Passed