QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#151848 | #6319. Parallel Processing (Easy) | Forever_Young# | AC ✓ | 1ms | 3928kb | C++14 | 2.7kb | 2023-08-27 14:46:01 | 2023-08-27 14:46:03 |
Judging History
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(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: 3928kb
input:
2
output:
1 2 1 2 1999 2000 2000 1999 2000 2000 1999 2000 2000
result:
ok AC
Test #2:
score: 0
Accepted
time: 1ms
memory: 3928kb
input:
4
output:
2 2 1 2 4 3 4 1999 2000 2000 1999 2000 2000 3 2 3 4 2 4 1999 2000 2000 1999 2000 2000
result:
ok AC
Test #3:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
3
output:
2 2 1 2 4 3 4 1999 2000 2000 1999 2000 2000 3 2 3 4 2 4 1999 2000 2000 1999 2000 2000
result:
ok AC
Test #4:
score: 0
Accepted
time: 1ms
memory: 3736kb
input:
5
output:
3 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
result:
ok AC
Test #5:
score: 0
Accepted
time: 1ms
memory: 3916kb
input:
6
output:
3 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
result:
ok AC
Test #6:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
7
output:
3 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
result:
ok AC
Test #7:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
8
output:
3 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
result:
ok AC
Test #8:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
9
output:
4 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
result:
ok AC
Test #9:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
10
output:
4 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
result:
ok AC
Test #10:
score: 0
Accepted
time: 1ms
memory: 3784kb
input:
11
output:
4 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
result:
ok AC
Test #11:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
12
output:
5 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 1999 2000 2000 10 9 10 11 9 11 12 9 12 13 9 13
result:
ok AC
Test #12:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
13
output:
5 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 1999 2000 2000 10 9 10 11 9 11 12 9 12 13 9 13
result:
ok AC
Test #13:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
14
output:
6 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
result:
ok AC
Test #14:
score: 0
Accepted
time: 1ms
memory: 3848kb
input:
15
output:
6 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
result:
ok AC
Test #15:
score: 0
Accepted
time: 1ms
memory: 3920kb
input:
16
output:
6 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
result:
ok AC