QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#72357#5176. 多控制反转zhoukangyang100 ✓2ms3432kbC++171.8kb2023-01-15 14:59:532023-01-15 15:00:59

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:00:59]
  • 评测
  • 测评结果:100
  • 用时:2ms
  • 内存:3432kb
  • [2023-01-15 14:59:53]
  • 提交

answer

//n = 1 :
//	3 0 n+1 n
//	flip n+1
//	3 0 n+1 n
//
//n = 2 :
//	3 0 1 n
//	
//n = 3 : 
//	3 0 1
//	
//0 1 1  
//
//xi.
//
//a b c
//c d e
//a b c
//c d e
//
//<=>
//
//a b d e
//
//
//0 1 2 3 [4] 5
//
//0 & 1 : flip 5
//5 & 1 : flip 2 
//
//DOIT(if (5 2 3 : FLIP 4))
//
//if 5 2 3 : FLIP 4
//
//[
//if 2 & 5 : FLIP 1
//FLIP 1
//if 1 & 3 : FLIP 2
//FLIP 2
//
//......
//
//back to ground!
//]
#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); ++i) 
#define R(i, j, k) for(int i = (j); i >= (k); --i) 
#define ll long long 
#define vi vector < int > 
#define ull unsigned long long 
#define sz(a) ((int) (a).size())
#define me(a, x) memset(a, x, sizeof(a)) 
using namespace std;
const int N = 1e5 + 7;
int n, m, q, CASE;
void solve(int pre, vi a) {
	if(sz(a) == 2) {
		cout << 3 << ' ' << a[0] << ' ' << a[1] << ' ' << n << '\n';
		return ;
	}
	cout << 3 << ' ' << a[0] << ' ' << a[1] << ' ' << pre << '\n';
	cout << 1 << ' ' << pre << '\n';
	vi cur = vi{pre};
	L(j, 2, sz(a) - 1) cur.emplace_back(a[j]); 
	solve(pre + 1, cur);
	cout << 1 << ' ' << pre << '\n';
	cout << 3 << ' ' << a[0] << ' ' << a[1] << ' ' << pre << '\n';
}
int main() {
	ios :: sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> q >> CASE;
	if(n == 0) {
		cout << 1 << '\n' << 1 << ' ' << 0 << '\n';
		return 0;
	}
	if(n == 1) {
		cout << 1 << '\n' << 2 << ' ' << 0 << ' ' << 1 << '\n';
		return 0;
	}
	if(n == 2) {
		cout << 1 << '\n' << 3 << ' ' << 0 << ' ' << 1 << ' ' << 2 << '\n';
		return 0;
	}
	cout << 8 * n - 20 << '\n';
	vi a = vi{n + 1};
	L(i, 2, n - 1) a.emplace_back(i);
	cout << 3 << ' ' << 0 << ' ' << 1 << ' ' << n + 1 << '\n';
	solve(1, a); 
	cout << 3 << ' ' << 0 << ' ' << 1 << ' ' << n + 1 << '\n';
	solve(1, a); 
	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: 3296kb

input:

0 2 1 1

output:

1
1 0

result:

ok OK.

Test #2:

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

input:

13 28 105 1

output:

84
3 0 1 14
3 14 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 13
1 10
3 9 11 10
1 9
3 8 10 9
1 8
3 7 9 8
1 7
3 6 8 7
1 6
3 5 7 6
1 5
3 4 6 5
1 4
3 3 5 4
1 3
3 2 4 3
1 2
3 1 3 2
1 1
3 14 2 1
3 0 1 14
3 14 2 1
1 1
3 1 3...

result:

ok OK.

Test #3:

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

input:

5 12 41 1

output:

20
3 0 1 6
3 6 2 1
1 1
3 1 3 2
1 2
3 2 4 5
1 2
3 1 3 2
1 1
3 6 2 1
3 0 1 6
3 6 2 1
1 1
3 1 3 2
1 2
3 2 4 5
1 2
3 1 3 2
1 1
3 6 2 1

result:

ok OK.

Test #4:

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

input:

20 42 161 1

output:

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

result:

ok OK.

Subtask #2:

score: 10
Accepted

Dependency #1:

100%
Accepted

Test #5:

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

input:

48 98 385 2

output:

364
3 0 1 49
3 49 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #6:

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

input:

41 84 329 2

output:

308
3 0 1 42
3 42 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #7:

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

input:

50 102 401 2

output:

380
3 0 1 51
3 51 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Subtask #3:

score: 10
Accepted

Dependency #2:

100%
Accepted

Test #8:

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

input:

0 2 1 3

output:

1
1 0

result:

ok OK.

Test #9:

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

input:

19 40 153 3

output:

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

result:

ok OK.

Test #10:

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

input:

47 96 377 3

output:

356
3 0 1 48
3 48 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #11:

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

input:

25 52 201 3

output:

180
3 0 1 26
3 26 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #12:

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

input:

50 102 401 3

output:

380
3 0 1 51
3 51 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Subtask #4:

score: 10
Accepted

Test #13:

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

input:

0 2 1 4

output:

1
1 0

result:

ok OK.

Test #14:

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

input:

18 20 325 4

output:

124
3 0 1 19
3 19 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 18
1 15
3 14 16 15
1 14
3 13 15 14
1 13
3 12 14 13
1 12
3 11 13 12
1 11
3 ...

result:

ok OK.

Test #15:

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

input:

14 16 197 4

output:

92
3 0 1 15
3 15 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 14
1 11
3 10 12 11
1 10
3 9 11 10
1 9
3 8 10 9
1 8
3 7 9 8
1 7
3 6 8 7
1 6
3 5 7 6
1 5
3 4 6 5
1 4
3 3 5 4
1 3
3 2 4 3
1 2
3 1 3 2
1 1
3 15...

result:

ok OK.

Test #16:

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

input:

20 22 401 4

output:

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

result:

ok OK.

Subtask #5:

score: 20
Accepted

Dependency #4:

100%
Accepted

Test #17:

score: 20
Accepted
time: 2ms
memory: 3408kb

input:

18 20 325 5

output:

124
3 0 1 19
3 19 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 18
1 15
3 14 16 15
1 14
3 13 15 14
1 13
3 12 14 13
1 12
3 11 13 12
1 11
3 ...

result:

ok OK.

Test #18:

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

input:

17 19 290 5

output:

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

result:

ok OK.

Test #19:

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

input:

20 22 401 5

output:

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

result:

ok OK.

Subtask #6:

score: 10
Accepted

Test #20:

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

input:

14 16 393 6

output:

92
3 0 1 15
3 15 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 14
1 11
3 10 12 11
1 10
3 9 11 10
1 9
3 8 10 9
1 8
3 7 9 8
1 7
3 6 8 7
1 6
3 5 7 6
1 5
3 4 6 5
1 4
3 3 5 4
1 3
3 2 4 3
1 2
3 1 3 2
1 1
3 15...

result:

ok OK.

Test #21:

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

input:

39 41 1093 6

output:

292
3 0 1 40
3 40 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #22:

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

input:

0 2 1 6

output:

1
1 0

result:

ok OK.

Test #23:

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

input:

50 52 1401 6

output:

380
3 0 1 51
3 51 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
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: 3432kb

input:

93 95 745 7

output:

724
3 0 1 94
3 94 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #25:

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

input:

82 84 657 7

output:

636
3 0 1 83
3 83 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #26:

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

input:

100 102 801 7

output:

780
3 0 1 101
3 101 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
...

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

input:

94 96 753 8

output:

732
3 0 1 95
3 95 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #28:

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

input:

70 72 561 8

output:

540
3 0 1 71
3 71 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
3 ...

result:

ok OK.

Test #29:

score: 0
Accepted
time: 1ms
memory: 3384kb

input:

100 102 801 8

output:

780
3 0 1 101
3 101 2 1
1 1
3 1 3 2
1 2
3 2 4 3
1 3
3 3 5 4
1 4
3 4 6 5
1 5
3 5 7 6
1 6
3 6 8 7
1 7
3 7 9 8
1 8
3 8 10 9
1 9
3 9 11 10
1 10
3 10 12 11
1 11
3 11 13 12
1 12
3 12 14 13
1 13
3 13 15 14
1 14
3 14 16 15
1 15
3 15 17 16
1 16
3 16 18 17
1 17
3 17 19 18
1 18
3 18 20 19
1 19
3 19 21 20
1 20
...

result:

ok OK.

Extra Test:

score: 0
Extra Test Passed