QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#818357#5176. 多控制反转pwx2009100 ✓1ms4064kbC++141.7kb2024-12-17 19:21:592024-12-17 19:21:59

Judging History

你现在查看的是最新测评结果

  • [2024-12-17 19:21:59]
  • 评测
  • 测评结果:100
  • 用时:1ms
  • 内存:4064kb
  • [2024-12-17 19:21:59]
  • 提交

answer

#include<cstdio>
#include<vector>
int n,Q,m,test;
struct node{
	int opt;
	int a,b,to;
};
std::vector<node>ans;
std::vector<int>A;
std::vector<int>B;
std::vector<int>C;
void solve(std::vector<int>x,std::vector<int>y,int z){
	int n=x.size();
	if(n==0){
		ans.push_back(node{1,0,0,z});
		return;
	}
	if(n==1){
		ans.push_back(node{2,x[0],0,z});
		return;
	}
	if(n==2){
		ans.push_back(node{3,x[0],x[1],z});
		return;
	}
	if(n==3){
		ans.push_back(node{3,x[0],x[1],y[0]});
		ans.push_back(node{3,x[2],y[0],z});
		ans.push_back(node{3,x[0],x[1],y[0]});
		ans.push_back(node{3,x[2],y[0],z});
		return;
	}
	ans.push_back(node{3,x[n-1],y[n-3],z});
	for(int i=n-2;i>=2;i--)ans.push_back(node{3,x[i],y[i-2],y[i-1]});
	ans.push_back(node{3,x[0],x[1],y[0]});
	for(int i=2;i<=n-2;i++)ans.push_back(node{3,x[i],y[i-2],y[i-1]});
	ans.push_back(node{3,x[n-1],y[n-3],z});
	for(int i=n-2;i>=2;i--)ans.push_back(node{3,x[i],y[i-2],y[i-1]});
	ans.push_back(node{3,x[0],x[1],y[0]});
	for(int i=2;i<=n-2;i++)ans.push_back(node{3,x[i],y[i-2],y[i-1]});
}
int main(){
//	freopen("bit.in","r",stdin);
//	freopen("bit.out","w",stdout);
	scanf("%d%d%d%d",&n,&m,&Q,&test);
	if(n==0){
		printf("1\n1 0");
		return 0;
	}
	for(int i=0;i<(n+1)/2;i++)A.push_back(i);
	for(int i=(n+1)/2;i<n;i++)B.push_back(i);
	for(int i=(n+1)/2;i<n;i++)C.push_back(i);
	C.push_back(n+1);
	solve(A,B,n+1);
	solve(C,A,n);
	solve(A,B,n+1);
	solve(C,A,n);
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();i++){
		switch(ans[i].opt){
			case 1:printf("1 %d\n",ans[i].to);break;
			case 2:printf("2 %d %d\n",ans[i].a,ans[i].to);break;
			case 3:printf("3 %d %d %d\n",ans[i].a,ans[i].b,ans[i].to);break;
		}
	}
	return 0;
}

詳細信息

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 0ms
memory: 3712kb

input:

0 2 1 1

output:

1
1 0

result:

ok OK.

Test #2:

score: 15
Accepted
time: 0ms
memory: 3996kb

input:

13 28 105 1

output:

80
3 6 11 14
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 14
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 14 4 13
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
3 12 3 4
3 14 4 13
3 12 3 4
3 11 2 3
3 10 ...

result:

ok OK.

Test #3:

score: 15
Accepted
time: 0ms
memory: 3732kb

input:

5 12 41 1

output:

16
3 0 1 3
3 2 3 6
3 0 1 3
3 2 3 6
3 3 4 0
3 6 0 5
3 3 4 0
3 6 0 5
3 0 1 3
3 2 3 6
3 0 1 3
3 2 3 6
3 3 4 0
3 6 0 5
3 3 4 0
3 6 0 5

result:

ok OK.

Test #4:

score: 15
Accepted
time: 0ms
memory: 3728kb

input:

20 42 161 1

output:

136
3 9 17 21
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 21
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 1...

result:

ok OK.

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 10
Accepted
time: 0ms
memory: 4044kb

input:

48 98 385 2

output:

360
3 23 45 49
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 28 29
3 7...

result:

ok OK.

Test #6:

score: 10
Accepted
time: 0ms
memory: 3780kb

input:

41 84 329 2

output:

304
3 20 39 42
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 29
3 10 2...

result:

ok OK.

Test #7:

score: 10
Accepted
time: 0ms
memory: 4032kb

input:

50 102 401 2

output:

376
3 24 47 51
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 28 29
3 ...

result:

ok OK.

Subtask #3:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #8:

score: 10
Accepted
time: 0ms
memory: 3976kb

input:

0 2 1 3

output:

1
1 0

result:

ok OK.

Test #9:

score: 10
Accepted
time: 0ms
memory: 3736kb

input:

19 40 153 3

output:

128
3 9 17 20
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 20
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 1...

result:

ok OK.

Test #10:

score: 10
Accepted
time: 0ms
memory: 3852kb

input:

47 96 377 3

output:

352
3 23 45 48
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 28 29
3 7...

result:

ok OK.

Test #11:

score: 10
Accepted
time: 1ms
memory: 3780kb

input:

25 52 201 3

output:

176
3 12 23 26
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 26
3 11 22 23
3 10 21 22
3 9 20 21
3 8 19 20
3 7 18 19
3 6 17 18...

result:

ok OK.

Test #12:

score: 10
Accepted
time: 0ms
memory: 3736kb

input:

50 102 401 3

output:

376
3 24 47 51
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 28 29
3 ...

result:

ok OK.

Subtask #4:

score: 10
Accepted

Test #13:

score: 10
Accepted
time: 0ms
memory: 3720kb

input:

0 2 1 4

output:

1
1 0

result:

ok OK.

Test #14:

score: 10
Accepted
time: 0ms
memory: 3732kb

input:

18 20 325 4

output:

120
3 8 15 19
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 19
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 19 7 18
3 17 6 7
3 16 ...

result:

ok OK.

Test #15:

score: 10
Accepted
time: 0ms
memory: 4024kb

input:

14 16 197 4

output:

88
3 6 11 15
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 15
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 15 5 14
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
3 11 2 3
3 12 3 4
3 13 4 5
3 15 5 14
3 13 ...

result:

ok OK.

Test #16:

score: 10
Accepted
time: 0ms
memory: 4040kb

input:

20 22 401 4

output:

136
3 9 17 21
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 21
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 1...

result:

ok OK.

Subtask #5:

score: 20
Accepted

Dependency #4:

100%
Accepted

Test #17:

score: 20
Accepted
time: 0ms
memory: 3744kb

input:

18 20 325 5

output:

120
3 8 15 19
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 19
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 19 7 18
3 17 6 7
3 16 ...

result:

ok OK.

Test #18:

score: 20
Accepted
time: 0ms
memory: 4020kb

input:

17 19 290 5

output:

112
3 8 15 18
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 18
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 18 6 17
3 16 5 6
3 15 ...

result:

ok OK.

Test #19:

score: 20
Accepted
time: 0ms
memory: 3776kb

input:

20 22 401 5

output:

136
3 9 17 21
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 21
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 1...

result:

ok OK.

Subtask #6:

score: 10
Accepted

Test #20:

score: 10
Accepted
time: 0ms
memory: 3732kb

input:

14 16 393 6

output:

88
3 6 11 15
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 15
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 15 5 14
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
3 11 2 3
3 12 3 4
3 13 4 5
3 15 5 14
3 13 ...

result:

ok OK.

Test #21:

score: 10
Accepted
time: 0ms
memory: 4044kb

input:

39 41 1093 6

output:

288
3 19 37 40
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 29
3 11 2...

result:

ok OK.

Test #22:

score: 10
Accepted
time: 0ms
memory: 3764kb

input:

0 2 1 6

output:

1
1 0

result:

ok OK.

Test #23:

score: 10
Accepted
time: 0ms
memory: 3740kb

input:

50 52 1401 6

output:

376
3 24 47 51
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 28 29
3 ...

result:

ok OK.

Subtask #7:

score: 10
Accepted

Dependency #2:

100%
Accepted

Dependency #4:

100%
Accepted

Test #24:

score: 10
Accepted
time: 0ms
memory: 3788kb

input:

93 95 745 7

output:

720
3 46 91 94
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 20 65 66...

result:

ok OK.

Test #25:

score: 10
Accepted
time: 1ms
memory: 3724kb

input:

82 84 657 7

output:

632
3 40 79 83
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 14 53 54...

result:

ok OK.

Test #26:

score: 10
Accepted
time: 1ms
memory: 3856kb

input:

100 102 801 7

output:

776
3 49 97 101
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 23 71 7...

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: 4064kb

input:

94 96 753 8

output:

728
3 46 91 95
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 20 65 66...

result:

ok OK.

Test #28:

score: 15
Accepted
time: 1ms
memory: 4052kb

input:

70 72 561 8

output:

536
3 34 67 71
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 41 42
3...

result:

ok OK.

Test #29:

score: 15
Accepted
time: 1ms
memory: 4064kb

input:

100 102 801 8

output:

776
3 49 97 101
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 23 71 7...

result:

ok OK.

Extra Test:

score: 0
Extra Test Passed