QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#151863#6320. Parallel Processing (Hard)Forever_Young#WA 1ms3624kbC++144.3kb2023-08-27 14:50:582023-08-27 14:51:00

Judging History

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

  • [2023-08-27 14:51:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3624kb
  • [2023-08-27 14:50:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
vector<array<int, 3> > ops;
const int L = 2000;
void _() {
	ops.pb({L - 1, L, L});
}
int i;
void _(int c, int a, int b) {
	ops.pb({i + c, i + a, i + b});
}
const bool debug = false;
int main() {
	int n;
	scanf("%d", &n);
	for(i = 0; i < n; i += 16) {
		int len = min(n, i + 16) - i;
		if(i == 0) {
			if(len == 1) {

			}else if(len == 2) {
				_(2, 1, 2);
				_();
				_();
				_();

			}else if(len <= 4) {
				_(2, 1, 2);
				_(4, 3, 4);
				_();
				_();
				_(3, 2, 3);
				_(4, 2, 4);
				_();
				_();
				
			}else if(len <= 8) {
				_(2, 1, 2);
				_(4, 3, 4);
				_(6, 5, 6);
				_(8, 7, 8);
				_(3, 2, 3);
				_(4, 2, 4);
				_(7, 6, 7);
				_(8, 6, 8);
				_(5, 4, 5);
				_(6, 4, 6);
				_(7, 4, 7);
				_(8, 4, 8);
			}else if(len <= 11) {
				_(2, 1, 2);
				_(4, 3, 4);
				_(6, 5, 6);
				_(9, 8, 9);

				_(3, 2, 3);
				_(4, 2, 4);
				_(7, 6, 7);
				_(10, 9, 10);

				_(5, 4, 5);
				_(6, 4, 6);
				_(7, 4, 7);
				_(11, 10, 11);

				_(8, 7, 8);
				_(9, 7, 9);
				_(10, 7, 10);
				_(11, 7, 11);
			}else if(len <= 13) {
				_(2, 1, 2);
				_(5, 4, 5);
				_(8, 7, 8);
				_(11, 10, 11);

				_(3, 2, 3);
				_(6, 5, 6);
				_(9, 8, 9);
				_(12, 11, 12);

				_(4, 3, 4);
				_(5, 3, 5);
				_(6, 3, 6);
				_(13, 12, 13);

				_(7, 6, 7);
				_(8, 6, 8);
				_(9, 6, 9);
				_();

				_(10, 9, 10);
				_(11, 9, 11);
				_(12, 9, 12);
				_(13, 9, 13);
			}else {

				for(int d = 0; d < 3; d++) {
					for(int e = 0; e < 4; e++) {
						_(e * 4 + d + 2, e * 4 + d + 1, e * 4 + d + 2);
					}
				}
				for(int d = 0; d < 3; d++) {
					for(int e = 0; e < 4; e++) {
						_((d + 1) * 4 + e + 1, (d + 1) * 4, (d + 1) * 4 + e + 1);
					}
				}
			}
		}else {
			_(1, 0, 1);
			_();
			_();
			_();
			if(len == 1) {
			}else if(len == 2) {
				_(2, 1, 2);
				_();
				_();
				_();
			}else if(len <= 4) {
				_(2, 1, 2);
				_(4, 3, 4);
				_();
				_();
				_(3, 2, 3);
				_(4, 2, 4);
				_();
				_();
			}else if(len <= 8) {
				_(2, 1, 2);
				_(4, 3, 4);
				_(6, 5, 6);
				_(8, 7, 8);
				_(3, 2, 3);
				_(4, 2, 4);
				_(7, 6, 7);
				_(8, 6, 8);
				_(5, 4, 5);
				_(6, 4, 6);
				_(7, 4, 7);
				_(8, 4, 8);
			}else if(len <= 11) {
				_(2, 1, 2);
				_(4, 3, 4);
				_(6, 5, 6);
				_(9, 8, 9);

				_(3, 2, 3);
				_(4, 2, 4);
				_(7, 6, 7);
				_(10, 9, 10);

				_(5, 4, 5);
				_(6, 4, 6);
				_(7, 4, 7);
				_(11, 10, 11);

				_(8, 7, 8);
				_(9, 7, 9);
				_(10, 7, 10);
				_(11, 7, 11);
			}else if(len <= 13) {
				_(2, 1, 2);
				_(5, 4, 5);
				_(8, 7, 8);
				_(11, 10, 11);

				_(3, 2, 3);
				_(6, 5, 6);
				_(9, 8, 9);
				_(12, 11, 12);

				_(4, 3, 4);
				_(5, 3, 5);
				_(6, 3, 6);
				_(13, 12, 13);

				_(7, 6, 7);
				_(8, 6, 8);
				_(9, 6, 9);
				_();

				_(10, 9, 10);
				_(11, 9, 11);
				_(12, 9, 12);
				_(13, 9, 13);
			}else {

				for(int d = 0; d < 3; d++) {
					for(int e = 0; e < 4; e++) {
						_(e * 4 + d + 2, e * 4 + d + 1, e * 4 + d + 2);
					}
				}
				for(int d = 0; d < 3; d++) {
					for(int e = 0; e < 4; e++) {
						_((d + 1) * 4 + e + 1, (d + 1) * 4, (d + 1) * 4 + e + 1);
					}
				}
			}
		}
	}
	while(ops.size() % 4 != 0) {
		_();
	}
	printf("%d\n", ops.size() / 4);
	for(int i = 0; i < (int)ops.size(); i++) {
		printf("%d %d %d\n", ops[i][0], ops[i][1], ops[i][2]);
	}
	if(debug) {
		vector<vector<int> > vec(L);
		for(int i = 0; i < L; i++) {
			vec[i].pb(i);
		}
		printf("%d\n", vec[0].size());
		for(int i = 0; i < (int)ops.size(); i += 4) {
			for(int d = 0; d < 4; d++) {
				for(int e = 0; e < 3; e++) {
					ops[i + d][e]--;
				}
			}
			vector<int> tmp[4];
			for(int d = 0; d < 4; d++) {
				if(ops[i + d][0] == L - 2) continue;
				tmp[d] = vec[ops[i + d][1]];
				tmp[d].insert(tmp[d].end(), all(vec[ops[i + d][2]]));
			}
			for(int d = 0; d < 4; d++) {
				if(ops[i + d][0] == L - 2) continue;
				vec[ops[i + d][0]] = move(tmp[d]);
			}
		}
		for(int i = 0; i < n; i++) {
			assert(vec[i].size() == i + 1);
			for(int j = 0; j < i; j++) {
				assert(vec[i][j] == j);
			}
		}
	}
}






Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3624kb

input:

17

output:

7
2 1 2
6 5 6
10 9 10
14 13 14
3 2 3
7 6 7
11 10 11
15 14 15
4 3 4
8 7 8
12 11 12
16 15 16
5 4 5
6 4 6
7 4 7
8 4 8
9 8 9
10 8 10
11 8 11
12 8 12
13 12 13
14 12 14
15 12 15
16 12 16
17 16 17
1999 2000 2000
1999 2000 2000
1999 2000 2000

result:

ok AC

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3624kb

input:

18

output:

8
2 1 2
6 5 6
10 9 10
14 13 14
3 2 3
7 6 7
11 10 11
15 14 15
4 3 4
8 7 8
12 11 12
16 15 16
5 4 5
6 4 6
7 4 7
8 4 8
9 8 9
10 8 10
11 8 11
12 8 12
13 12 13
14 12 14
15 12 15
16 12 16
17 16 17
1999 2000 2000
1999 2000 2000
1999 2000 2000
18 17 18
1999 2000 2000
1999 2000 2000
1999 2000 2000

result:

wrong answer L = 8 is larger than 7