QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#72413#5176. 多控制反转He_Ren100 ✓2ms3652kbC++231.7kb2023-01-15 15:24:482023-01-15 15:25:20

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-15 15:25:20]
  • 评测
  • 测评结果:100
  • 用时:2ms
  • 内存:3652kb
  • [2023-01-15 15:24:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 100 + 5;

struct Oper
{
	int x,y,z;
	Oper(int _x=-1,int _y=-1,int _z=-1): x(_x), y(_y), z(_z) {}
	void print(void) const
	{
		if(z != -1)
			printf("3 %d %d %d\n",x,y,z);
		else if(y != -1)
			printf("2 %d %d\n",x,y);
		else
			printf("1 %d\n",x);
	}
};

int n,m;
vector<Oper> ans;

void printans(void)
{
	printf("%d\n",(int)ans.size());
	for(auto t: ans)
		t.print();
	exit(0);
}

void gao(vector<int> pos,int goal,vector<int> tmp)
{
	if(pos.size() == 0)
	{
		ans.emplace_back(goal);
		return;
	}
	if(pos.size() == 1)
	{
		ans.emplace_back(pos[0], goal);
		return;
	}
	if(pos.size() == 2)
	{
		ans.emplace_back(pos[0], pos[1], goal);
		return;
	}
	
	int i = pos.back(), j = tmp.back();
	pos.pop_back(); tmp.pop_back();
	
	ans.emplace_back(i, j, goal);
	gao(pos, j, tmp);
	ans.emplace_back(i, j, goal);
}

void gao2(vector<int> pos, int goal, vector<int> tmp)
{
	gao(pos, goal, tmp);
	if(pos.size() > 2)
	{
		int j = tmp.back();
		pos.pop_back(); tmp.pop_back();
		
		gao(pos, j, tmp);
	}
}

int main(void)
{
	int Q,subid;
	scanf("%d%d%d%d",&n,&m,&Q,&subid);
	
	if(n == 0)
	{
		ans.emplace_back(n);
		printans();
	}
	if(n == 1)
	{
		ans.emplace_back(0, n);
		printans();
	}
	if(n == 2)
	{
		ans.emplace_back(0, 1, n);
		printans();
	}
	
	int mid = (n + 1) / 2;
	vector<int> lef(mid), rig(n - mid);
	iota(lef.begin(), lef.end(), 0);
	iota(rig.begin(), rig.end(), mid);
	
	auto rig1 = rig, rig2 = rig;
	rig1.emplace_back(n);
	rig2.emplace_back(n+1);
	
	gao2(lef, n+1, rig1);
	gao2(rig2, n, lef);
	
	gao2(lef, n+1, rig1);
	gao2(rig2, n, lef);
	
	printans();
	return 0;
}

詳細信息

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 2ms
memory: 3552kb

input:

0 2 1 1

output:

1
1 0

result:

ok OK.

Test #2:

score: 0
Accepted
time: 2ms
memory: 3568kb

input:

13 28 105 1

output:

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

result:

ok OK.

Test #3:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

5 12 41 1

output:

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

result:

ok OK.

Test #4:

score: 0
Accepted
time: 2ms
memory: 3636kb

input:

20 42 161 1

output:

136
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 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 1...

result:

ok OK.

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 10
Accepted
time: 2ms
memory: 3496kb

input:

48 98 385 2

output:

360
3 23 48 49
3 22 47 48
3 21 46 47
3 20 45 46
3 19 44 45
3 18 43 44
3 17 42 43
3 16 41 42
3 15 40 41
3 14 39 40
3 13 38 39
3 12 37 38
3 11 36 37
3 10 35 36
3 9 34 35
3 8 33 34
3 7 32 33
3 6 31 32
3 5 30 31
3 4 29 30
3 3 28 29
3 2 27 28
3 0 1 27
3 2 27 28
3 3 28 29
3 4 29 30
3 5 30 31
3 6 31 32
3 7...

result:

ok OK.

Test #6:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

41 84 329 2

output:

304
3 20 41 42
3 19 40 41
3 18 39 40
3 17 38 39
3 16 37 38
3 15 36 37
3 14 35 36
3 13 34 35
3 12 33 34
3 11 32 33
3 10 31 32
3 9 30 31
3 8 29 30
3 7 28 29
3 6 27 28
3 5 26 27
3 4 25 26
3 3 24 25
3 2 23 24
3 0 1 23
3 2 23 24
3 3 24 25
3 4 25 26
3 5 26 27
3 6 27 28
3 7 28 29
3 8 29 30
3 9 30 31
3 10 3...

result:

ok OK.

Test #7:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

50 102 401 2

output:

376
3 24 50 51
3 23 49 50
3 22 48 49
3 21 47 48
3 20 46 47
3 19 45 46
3 18 44 45
3 17 43 44
3 16 42 43
3 15 41 42
3 14 40 41
3 13 39 40
3 12 38 39
3 11 37 38
3 10 36 37
3 9 35 36
3 8 34 35
3 7 33 34
3 6 32 33
3 5 31 32
3 4 30 31
3 3 29 30
3 2 28 29
3 0 1 28
3 2 28 29
3 3 29 30
3 4 30 31
3 5 31 32
3 ...

result:

ok OK.

Subtask #3:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #8:

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

input:

0 2 1 3

output:

1
1 0

result:

ok OK.

Test #9:

score: 0
Accepted
time: 2ms
memory: 3532kb

input:

19 40 153 3

output:

128
3 9 19 20
3 8 18 19
3 7 17 18
3 6 16 17
3 5 15 16
3 4 14 15
3 3 13 14
3 2 12 13
3 0 1 12
3 2 12 13
3 3 13 14
3 4 14 15
3 5 15 16
3 6 16 17
3 7 17 18
3 8 18 19
3 9 19 20
3 8 18 19
3 7 17 18
3 6 16 17
3 5 15 16
3 4 14 15
3 3 13 14
3 2 12 13
3 0 1 12
3 2 12 13
3 3 13 14
3 4 14 15
3 5 15 16
3 6 16 1...

result:

ok OK.

Test #10:

score: 0
Accepted
time: 2ms
memory: 3640kb

input:

47 96 377 3

output:

352
3 23 47 48
3 22 46 47
3 21 45 46
3 20 44 45
3 19 43 44
3 18 42 43
3 17 41 42
3 16 40 41
3 15 39 40
3 14 38 39
3 13 37 38
3 12 36 37
3 11 35 36
3 10 34 35
3 9 33 34
3 8 32 33
3 7 31 32
3 6 30 31
3 5 29 30
3 4 28 29
3 3 27 28
3 2 26 27
3 0 1 26
3 2 26 27
3 3 27 28
3 4 28 29
3 5 29 30
3 6 30 31
3 7...

result:

ok OK.

Test #11:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

25 52 201 3

output:

176
3 12 25 26
3 11 24 25
3 10 23 24
3 9 22 23
3 8 21 22
3 7 20 21
3 6 19 20
3 5 18 19
3 4 17 18
3 3 16 17
3 2 15 16
3 0 1 15
3 2 15 16
3 3 16 17
3 4 17 18
3 5 18 19
3 6 19 20
3 7 20 21
3 8 21 22
3 9 22 23
3 10 23 24
3 11 24 25
3 12 25 26
3 11 24 25
3 10 23 24
3 9 22 23
3 8 21 22
3 7 20 21
3 6 19 20...

result:

ok OK.

Test #12:

score: 0
Accepted
time: 2ms
memory: 3548kb

input:

50 102 401 3

output:

376
3 24 50 51
3 23 49 50
3 22 48 49
3 21 47 48
3 20 46 47
3 19 45 46
3 18 44 45
3 17 43 44
3 16 42 43
3 15 41 42
3 14 40 41
3 13 39 40
3 12 38 39
3 11 37 38
3 10 36 37
3 9 35 36
3 8 34 35
3 7 33 34
3 6 32 33
3 5 31 32
3 4 30 31
3 3 29 30
3 2 28 29
3 0 1 28
3 2 28 29
3 3 29 30
3 4 30 31
3 5 31 32
3 ...

result:

ok OK.

Subtask #4:

score: 10
Accepted

Test #13:

score: 10
Accepted
time: 2ms
memory: 3624kb

input:

0 2 1 4

output:

1
1 0

result:

ok OK.

Test #14:

score: 0
Accepted
time: 2ms
memory: 3536kb

input:

18 20 325 4

output:

120
3 8 18 19
3 7 17 18
3 6 16 17
3 5 15 16
3 4 14 15
3 3 13 14
3 2 12 13
3 0 1 12
3 2 12 13
3 3 13 14
3 4 14 15
3 5 15 16
3 6 16 17
3 7 17 18
3 8 18 19
3 7 17 18
3 6 16 17
3 5 15 16
3 4 14 15
3 3 13 14
3 2 12 13
3 0 1 12
3 2 12 13
3 3 13 14
3 4 14 15
3 5 15 16
3 6 16 17
3 7 17 18
3 19 8 18
3 17 7 8...

result:

ok OK.

Test #15:

score: 0
Accepted
time: 2ms
memory: 3488kb

input:

14 16 197 4

output:

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

result:

ok OK.

Test #16:

score: 0
Accepted
time: 2ms
memory: 3600kb

input:

20 22 401 4

output:

136
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 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 1...

result:

ok OK.

Subtask #5:

score: 20
Accepted

Dependency #4:

100%
Accepted

Test #17:

score: 20
Accepted
time: 1ms
memory: 3548kb

input:

18 20 325 5

output:

120
3 8 18 19
3 7 17 18
3 6 16 17
3 5 15 16
3 4 14 15
3 3 13 14
3 2 12 13
3 0 1 12
3 2 12 13
3 3 13 14
3 4 14 15
3 5 15 16
3 6 16 17
3 7 17 18
3 8 18 19
3 7 17 18
3 6 16 17
3 5 15 16
3 4 14 15
3 3 13 14
3 2 12 13
3 0 1 12
3 2 12 13
3 3 13 14
3 4 14 15
3 5 15 16
3 6 16 17
3 7 17 18
3 19 8 18
3 17 7 8...

result:

ok OK.

Test #18:

score: 0
Accepted
time: 2ms
memory: 3652kb

input:

17 19 290 5

output:

112
3 8 17 18
3 7 16 17
3 6 15 16
3 5 14 15
3 4 13 14
3 3 12 13
3 2 11 12
3 0 1 11
3 2 11 12
3 3 12 13
3 4 13 14
3 5 14 15
3 6 15 16
3 7 16 17
3 8 17 18
3 7 16 17
3 6 15 16
3 5 14 15
3 4 13 14
3 3 12 13
3 2 11 12
3 0 1 11
3 2 11 12
3 3 12 13
3 4 13 14
3 5 14 15
3 6 15 16
3 7 16 17
3 18 8 17
3 16 7 8...

result:

ok OK.

Test #19:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

20 22 401 5

output:

136
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 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 1...

result:

ok OK.

Subtask #6:

score: 10
Accepted

Test #20:

score: 10
Accepted
time: 2ms
memory: 3564kb

input:

14 16 393 6

output:

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

result:

ok OK.

Test #21:

score: 0
Accepted
time: 2ms
memory: 3564kb

input:

39 41 1093 6

output:

288
3 19 39 40
3 18 38 39
3 17 37 38
3 16 36 37
3 15 35 36
3 14 34 35
3 13 33 34
3 12 32 33
3 11 31 32
3 10 30 31
3 9 29 30
3 8 28 29
3 7 27 28
3 6 26 27
3 5 25 26
3 4 24 25
3 3 23 24
3 2 22 23
3 0 1 22
3 2 22 23
3 3 23 24
3 4 24 25
3 5 25 26
3 6 26 27
3 7 27 28
3 8 28 29
3 9 29 30
3 10 30 31
3 11 3...

result:

ok OK.

Test #22:

score: 0
Accepted
time: 2ms
memory: 3540kb

input:

0 2 1 6

output:

1
1 0

result:

ok OK.

Test #23:

score: 0
Accepted
time: 2ms
memory: 3560kb

input:

50 52 1401 6

output:

376
3 24 50 51
3 23 49 50
3 22 48 49
3 21 47 48
3 20 46 47
3 19 45 46
3 18 44 45
3 17 43 44
3 16 42 43
3 15 41 42
3 14 40 41
3 13 39 40
3 12 38 39
3 11 37 38
3 10 36 37
3 9 35 36
3 8 34 35
3 7 33 34
3 6 32 33
3 5 31 32
3 4 30 31
3 3 29 30
3 2 28 29
3 0 1 28
3 2 28 29
3 3 29 30
3 4 30 31
3 5 31 32
3 ...

result:

ok OK.

Subtask #7:

score: 10
Accepted

Dependency #2:

100%
Accepted

Dependency #4:

100%
Accepted

Test #24:

score: 10
Accepted
time: 2ms
memory: 3576kb

input:

93 95 745 7

output:

720
3 46 93 94
3 45 92 93
3 44 91 92
3 43 90 91
3 42 89 90
3 41 88 89
3 40 87 88
3 39 86 87
3 38 85 86
3 37 84 85
3 36 83 84
3 35 82 83
3 34 81 82
3 33 80 81
3 32 79 80
3 31 78 79
3 30 77 78
3 29 76 77
3 28 75 76
3 27 74 75
3 26 73 74
3 25 72 73
3 24 71 72
3 23 70 71
3 22 69 70
3 21 68 69
3 20 67 68...

result:

ok OK.

Test #25:

score: 0
Accepted
time: 2ms
memory: 3572kb

input:

82 84 657 7

output:

632
3 40 82 83
3 39 81 82
3 38 80 81
3 37 79 80
3 36 78 79
3 35 77 78
3 34 76 77
3 33 75 76
3 32 74 75
3 31 73 74
3 30 72 73
3 29 71 72
3 28 70 71
3 27 69 70
3 26 68 69
3 25 67 68
3 24 66 67
3 23 65 66
3 22 64 65
3 21 63 64
3 20 62 63
3 19 61 62
3 18 60 61
3 17 59 60
3 16 58 59
3 15 57 58
3 14 56 57...

result:

ok OK.

Test #26:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

100 102 801 7

output:

776
3 49 100 101
3 48 99 100
3 47 98 99
3 46 97 98
3 45 96 97
3 44 95 96
3 43 94 95
3 42 93 94
3 41 92 93
3 40 91 92
3 39 90 91
3 38 89 90
3 37 88 89
3 36 87 88
3 35 86 87
3 34 85 86
3 33 84 85
3 32 83 84
3 31 82 83
3 30 81 82
3 29 80 81
3 28 79 80
3 27 78 79
3 26 77 78
3 25 76 77
3 24 75 76
3 23 74...

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

input:

94 96 753 8

output:

728
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 72
3 22 70 71
3 21 69 70
3 20 68 69...

result:

ok OK.

Test #28:

score: 0
Accepted
time: 0ms
memory: 3524kb

input:

70 72 561 8

output:

536
3 34 70 71
3 33 69 70
3 32 68 69
3 31 67 68
3 30 66 67
3 29 65 66
3 28 64 65
3 27 63 64
3 26 62 63
3 25 61 62
3 24 60 61
3 23 59 60
3 22 58 59
3 21 57 58
3 20 56 57
3 19 55 56
3 18 54 55
3 17 53 54
3 16 52 53
3 15 51 52
3 14 50 51
3 13 49 50
3 12 48 49
3 11 47 48
3 10 46 47
3 9 45 46
3 8 44 45
3...

result:

ok OK.

Test #29:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

100 102 801 8

output:

776
3 49 100 101
3 48 99 100
3 47 98 99
3 46 97 98
3 45 96 97
3 44 95 96
3 43 94 95
3 42 93 94
3 41 92 93
3 40 91 92
3 39 90 91
3 38 89 90
3 37 88 89
3 36 87 88
3 35 86 87
3 34 85 86
3 33 84 85
3 32 83 84
3 31 82 83
3 30 81 82
3 29 80 81
3 28 79 80
3 27 78 79
3 26 77 78
3 25 76 77
3 24 75 76
3 23 74...

result:

ok OK.

Extra Test:

score: 0
Extra Test Passed