QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#312561 | #6319. Parallel Processing (Easy) | PlentyOfPenalty | RE | 1ms | 3816kb | C++20 | 3.6kb | 2024-01-23 23:59:05 | 2024-01-23 23:59:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 9;
struct atom {
int l, r;
atom operator+(const atom &rhs) const {
assert(r + 1 == rhs.l);
return {l, rhs.r};
}
} a[N], c[4];
int n;
struct oper {
int a, b, c;
bool ok() const { return a && b && c && a <= n && b <= n && c <= n; }
};
vector<array<oper, 4>> ans;
int main() {
#ifdef popteam
freopen("C.in", "r", stdin);
#endif
for (int i = 0; i < N; i++)
a[i].l = a[i].r = i;
cin.tie(0)->sync_with_stdio(0);
cin >> n;
if (n >= 2)
ans.push_back({
oper{1, 2, 2},
oper{3, 4, 4},
oper{5, 6, 6},
oper{7, 8, 8},
});
if (n >= 3)
ans.push_back({
oper{2, 3, 3}, // ???? ans[1][0]
oper{2, 4, 4},
oper{6, 7, 7},
oper{6, 8, 8},
});
if (n >= 5)
ans.push_back({
oper{4, 5, 5}, // ???? ans[2][0]
oper{4, 6, 6}, // ???? ans[2][1]
oper{4, 7, 7}, // ???? ans[2][2]
oper{4, 8, 8},
});
if (n >= 9)
ans.push_back({
oper{8, 9, 9},
oper{8, 10, 10},
oper{8, 11, 11},
oper{8, 12, 12},
});
if (n >= 13)
ans.push_back({
oper{8, 13, 13},
oper{8, 14, 14},
oper{8, 15, 15},
oper{8, 16, 16},
});
if (n > 9) {
if (n == 10) {
ans[3][2] = {9, 10, 10};
swap(ans[3][2], ans[1][0]);
} else if (n == 11) {
ans[3][2] = {9, 10, 10};
ans[3][3] = {10, 11, 11};
swap(ans[3][2], ans[1][0]);
swap(ans[3][3], ans[2][0]);
} else if (n == 12) {
ans.insert(ans.begin() + 3, {
oper{9, 10, 10},
oper{10, 11, 11},
oper{11, 12, 12},
oper{10, 12, 12},
});
swap(ans[1][0], ans[3][0]);
swap(ans[2][0], ans[3][1]);
swap(ans[2][1], ans[3][2]);
// if (n == 13 || n == 14) {
// ans.insert(ans.begin() + 4, {
// oper{12, 13, 13},
// oper{13, 14, 14},
// });
// swap(ans[2][2], ans[4][0]);
// }
} else {
auto tmp = ans;
for (int i = 0; i < 3; i++)
for (int j = 0; j < 4; j++) {
tmp[i][j].a += 8;
tmp[i][j].b += 8;
tmp[i][j].c += 8;
}
ans.insert(ans.begin() + 3, tmp[0]);
ans.insert(ans.begin() + 4, tmp[1]);
ans.insert(ans.begin() + 5, tmp[2]);
}
}
cout << ans.size() << endl;
for (const auto &op : ans) {
for (int i = 0; i < 4; i++)
if (op[i].ok()) {
cout << op[i].b << " " << op[i].a << " " << op[i].c << endl;
c[i] = a[op[i].a] + a[op[i].b];
} else {
cout << "2000 2000 2000" << endl;
}
for (int i = 0; i < 4; i++)
if (op[i].ok()) a[op[i].c] = c[i];
cerr << ">> ";
for (int i = 1; i <= n; i++)
cerr << a[i].l << "," << a[i].r << " ";
cerr << endl;
}
for (int i = 1; i <= n; i++) {
assert(a[i].l == 1 && a[i].r == i);
}
cerr << "size = " << ans.size() << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
2
output:
1 2 1 2 2000 2000 2000 2000 2000 2000 2000 2000 2000
result:
ok AC
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
4
output:
2 2 1 2 4 3 4 2000 2000 2000 2000 2000 2000 3 2 3 4 2 4 2000 2000 2000 2000 2000 2000
result:
ok AC
Test #3:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
3
output:
2 2 1 2 2000 2000 2000 2000 2000 2000 2000 2000 2000 3 2 3 2000 2000 2000 2000 2000 2000 2000 2000 2000
result:
ok AC
Test #4:
score: 0
Accepted
time: 1ms
memory: 3816kb
input:
5
output:
3 2 1 2 4 3 4 2000 2000 2000 2000 2000 2000 3 2 3 4 2 4 2000 2000 2000 2000 2000 2000 5 4 5 2000 2000 2000 2000 2000 2000 2000 2000 2000
result:
ok AC
Test #5:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
6
output:
3 2 1 2 4 3 4 6 5 6 2000 2000 2000 3 2 3 4 2 4 2000 2000 2000 2000 2000 2000 5 4 5 6 4 6 2000 2000 2000 2000 2000 2000
result:
ok AC
Test #6:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
7
output:
3 2 1 2 4 3 4 6 5 6 2000 2000 2000 3 2 3 4 2 4 7 6 7 2000 2000 2000 5 4 5 6 4 6 7 4 7 2000 2000 2000
result:
ok AC
Test #7:
score: 0
Accepted
time: 1ms
memory: 3504kb
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: 3620kb
input:
9
output:
4 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 9 8 9 2000 2000 2000 2000 2000 2000 2000 2000 2000
result:
ok AC
Test #9:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
10
output:
4 2 1 2 4 3 4 6 5 6 8 7 8 10 9 10 4 2 4 7 6 7 8 6 8 5 4 5 6 4 6 7 4 7 8 4 8 9 8 9 10 8 10 3 2 3 2000 2000 2000
result:
ok AC
Test #10:
score: -100
Runtime Error
input:
11
output:
4 2 1 2 4 3 4 6 5 6 8 7 8 10 9 10 4 2 4 7 6 7 8 6 8 11 10 11 6 4 6 7 4 7 8 4 8 9 8 9 10 8 10 3 2 3 5 4 5