QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#289931 | #7263. Team Competition | elimva | AC ✓ | 98ms | 16812kb | C++20 | 1.5kb | 2023-12-24 05:29:48 | 2023-12-24 05:29:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i <= e; ++i)
#define per(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)
#define pv(a) cout << #a << " = " << a << endl
#define pa(a, l, r) cout << #a " : "; rep(_, l, r) cout << a[_] << " \n"[_ == r]
const int N = 1e3 + 10;
int read() {
int x = 0, f = 1; char c = getchar();
for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1;
for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + (c - 48);
return x * f;
}
int n;
vector <tuple <int, int, int>> ans;
void f(int i, int j, int k) {
assert(i != j && i != k && j != k);
if (i > j) swap(i, j);
if (j > k) swap(j, k);
if (i > j) swap(i, j);
ans.emplace_back(make_tuple(i, j, k));
}
int main() {
n = read();
if (n & 1) {
rep(i, 1, n) rep(d, 1, (n - 1) / 2) {
int j = (i - d - 1 + n) % n + 1;
int k = (i + d - 1) % n + 1;
f(i, j, k);
}
}
else {
--n;
rep(i, 1, n) rep(d, 1, (n - 1) / 2) {
int j = (i - d - 1 + n) % n + 1;
int k = (i + d - 1) % n + 1;
f(i, j, k);
if (d > 1) f(i, j, k);
}
++n;
rep(i, 1, n - 1) {
f(n, i, i % (n - 1) + 1);
f(n, i, i % (n - 1) + 1);
f(n, i, (i + 1) % (n - 1) + 1);
}
}
printf("%d\n", (int) ans.size());
for (auto [i, j, k] : ans) {
printf("%d %d %d\n", i, j, k);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
5
output:
10 1 2 5 1 3 4 1 2 3 2 4 5 2 3 4 1 3 5 3 4 5 1 2 4 1 4 5 2 3 5
result:
ok good.
Test #2:
score: 0
Accepted
time: 45ms
memory: 10220kb
input:
995
output:
494515 1 2 995 1 3 994 1 4 993 1 5 992 1 6 991 1 7 990 1 8 989 1 9 988 1 10 987 1 11 986 1 12 985 1 13 984 1 14 983 1 15 982 1 16 981 1 17 980 1 18 979 1 19 978 1 20 977 1 21 976 1 22 975 1 23 974 1 24 973 1 25 972 1 26 971 1 27 970 1 28 969 1 29 968 1 30 967 1 31 966 1 32 965 1 33 964 1 34 963 1 35...
result:
ok good.
Test #3:
score: 0
Accepted
time: 88ms
memory: 16444kb
input:
996
output:
991020 1 2 995 1 3 994 1 3 994 1 4 993 1 4 993 1 5 992 1 5 992 1 6 991 1 6 991 1 7 990 1 7 990 1 8 989 1 8 989 1 9 988 1 9 988 1 10 987 1 10 987 1 11 986 1 11 986 1 12 985 1 12 985 1 13 984 1 13 984 1 14 983 1 14 983 1 15 982 1 15 982 1 16 981 1 16 981 1 17 980 1 17 980 1 18 979 1 18 979 1 19 978 1 ...
result:
ok good.
Test #4:
score: 0
Accepted
time: 49ms
memory: 10236kb
input:
997
output:
496506 1 2 997 1 3 996 1 4 995 1 5 994 1 6 993 1 7 992 1 8 991 1 9 990 1 10 989 1 11 988 1 12 987 1 13 986 1 14 985 1 15 984 1 16 983 1 17 982 1 18 981 1 19 980 1 20 979 1 21 978 1 22 977 1 23 976 1 24 975 1 25 974 1 26 973 1 27 972 1 28 971 1 29 970 1 30 969 1 31 968 1 32 967 1 33 966 1 34 965 1 35...
result:
ok good.
Test #5:
score: 0
Accepted
time: 96ms
memory: 15724kb
input:
998
output:
995006 1 2 997 1 3 996 1 3 996 1 4 995 1 4 995 1 5 994 1 5 994 1 6 993 1 6 993 1 7 992 1 7 992 1 8 991 1 8 991 1 9 990 1 9 990 1 10 989 1 10 989 1 11 988 1 11 988 1 12 987 1 12 987 1 13 986 1 13 986 1 14 985 1 14 985 1 15 984 1 15 984 1 16 983 1 16 983 1 17 982 1 17 982 1 18 981 1 18 981 1 19 980 1 ...
result:
ok good.
Test #6:
score: 0
Accepted
time: 47ms
memory: 10332kb
input:
999
output:
498501 1 2 999 1 3 998 1 4 997 1 5 996 1 6 995 1 7 994 1 8 993 1 9 992 1 10 991 1 11 990 1 12 989 1 13 988 1 14 987 1 15 986 1 16 985 1 17 984 1 18 983 1 19 982 1 20 981 1 21 980 1 22 979 1 23 978 1 24 977 1 25 976 1 26 975 1 27 974 1 28 973 1 29 972 1 30 971 1 31 970 1 32 969 1 33 968 1 34 967 1 35...
result:
ok good.
Test #7:
score: 0
Accepted
time: 98ms
memory: 16812kb
input:
1000
output:
999000 1 2 999 1 3 998 1 3 998 1 4 997 1 4 997 1 5 996 1 5 996 1 6 995 1 6 995 1 7 994 1 7 994 1 8 993 1 8 993 1 9 992 1 9 992 1 10 991 1 10 991 1 11 990 1 11 990 1 12 989 1 12 989 1 13 988 1 13 988 1 14 987 1 14 987 1 15 986 1 15 986 1 16 985 1 16 985 1 17 984 1 17 984 1 18 983 1 18 983 1 19 982 1 ...
result:
ok good.
Test #8:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
3
output:
3 1 2 3 1 2 3 1 2 3
result:
ok good.
Test #9:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
4
output:
12 1 2 3 1 2 3 1 2 3 1 2 4 1 2 4 1 3 4 2 3 4 2 3 4 1 2 4 1 3 4 1 3 4 2 3 4
result:
ok good.
Test #10:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
5
output:
10 1 2 5 1 3 4 1 2 3 2 4 5 2 3 4 1 3 5 3 4 5 1 2 4 1 4 5 2 3 5
result:
ok good.
Test #11:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
6
output:
30 1 2 5 1 3 4 1 3 4 1 2 3 2 4 5 2 4 5 2 3 4 1 3 5 1 3 5 3 4 5 1 2 4 1 2 4 1 4 5 2 3 5 2 3 5 1 2 6 1 2 6 1 3 6 2 3 6 2 3 6 2 4 6 3 4 6 3 4 6 3 5 6 4 5 6 4 5 6 1 4 6 1 5 6 1 5 6 2 5 6
result:
ok good.
Test #12:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
7
output:
21 1 2 7 1 3 6 1 4 5 1 2 3 2 4 7 2 5 6 2 3 4 1 3 5 3 6 7 3 4 5 2 4 6 1 4 7 4 5 6 3 5 7 1 2 5 5 6 7 1 4 6 2 3 6 1 6 7 2 5 7 3 4 7
result:
ok good.
Test #13:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
8
output:
56 1 2 7 1 3 6 1 3 6 1 4 5 1 4 5 1 2 3 2 4 7 2 4 7 2 5 6 2 5 6 2 3 4 1 3 5 1 3 5 3 6 7 3 6 7 3 4 5 2 4 6 2 4 6 1 4 7 1 4 7 4 5 6 3 5 7 3 5 7 1 2 5 1 2 5 5 6 7 1 4 6 1 4 6 2 3 6 2 3 6 1 6 7 2 5 7 2 5 7 3 4 7 3 4 7 1 2 8 1 2 8 1 3 8 2 3 8 2 3 8 2 4 8 3 4 8 3 4 8 3 5 8 4 5 8 4 5 8 4 6 8 5 6 8 5 6 8 5 7...
result:
ok good.
Test #14:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
9
output:
36 1 2 9 1 3 8 1 4 7 1 5 6 1 2 3 2 4 9 2 5 8 2 6 7 2 3 4 1 3 5 3 6 9 3 7 8 3 4 5 2 4 6 1 4 7 4 8 9 4 5 6 3 5 7 2 5 8 1 5 9 5 6 7 4 6 8 3 6 9 1 2 6 6 7 8 5 7 9 1 4 7 2 3 7 7 8 9 1 6 8 2 5 8 3 4 8 1 8 9 2 7 9 3 6 9 4 5 9
result:
ok good.
Test #15:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
10
output:
90 1 2 9 1 3 8 1 3 8 1 4 7 1 4 7 1 5 6 1 5 6 1 2 3 2 4 9 2 4 9 2 5 8 2 5 8 2 6 7 2 6 7 2 3 4 1 3 5 1 3 5 3 6 9 3 6 9 3 7 8 3 7 8 3 4 5 2 4 6 2 4 6 1 4 7 1 4 7 4 8 9 4 8 9 4 5 6 3 5 7 3 5 7 2 5 8 2 5 8 1 5 9 1 5 9 5 6 7 4 6 8 4 6 8 3 6 9 3 6 9 1 2 6 1 2 6 6 7 8 5 7 9 5 7 9 1 4 7 1 4 7 2 3 7 2 3 7 7 8...
result:
ok good.
Test #16:
score: 0
Accepted
time: 92ms
memory: 15664kb
input:
974
output:
947702 1 2 973 1 3 972 1 3 972 1 4 971 1 4 971 1 5 970 1 5 970 1 6 969 1 6 969 1 7 968 1 7 968 1 8 967 1 8 967 1 9 966 1 9 966 1 10 965 1 10 965 1 11 964 1 11 964 1 12 963 1 12 963 1 13 962 1 13 962 1 14 961 1 14 961 1 15 960 1 15 960 1 16 959 1 16 959 1 17 958 1 17 958 1 18 957 1 18 957 1 19 956 1 ...
result:
ok good.
Test #17:
score: 0
Accepted
time: 1ms
memory: 3884kb
input:
85
output:
3570 1 2 85 1 3 84 1 4 83 1 5 82 1 6 81 1 7 80 1 8 79 1 9 78 1 10 77 1 11 76 1 12 75 1 13 74 1 14 73 1 15 72 1 16 71 1 17 70 1 18 69 1 19 68 1 20 67 1 21 66 1 22 65 1 23 64 1 24 63 1 25 62 1 26 61 1 27 60 1 28 59 1 29 58 1 30 57 1 31 56 1 32 55 1 33 54 1 34 53 1 35 52 1 36 51 1 37 50 1 38 49 1 39 48...
result:
ok good.
Test #18:
score: 0
Accepted
time: 19ms
memory: 7788kb
input:
456
output:
207480 1 2 455 1 3 454 1 3 454 1 4 453 1 4 453 1 5 452 1 5 452 1 6 451 1 6 451 1 7 450 1 7 450 1 8 449 1 8 449 1 9 448 1 9 448 1 10 447 1 10 447 1 11 446 1 11 446 1 12 445 1 12 445 1 13 444 1 13 444 1 14 443 1 14 443 1 15 442 1 15 442 1 16 441 1 16 441 1 17 440 1 17 440 1 18 439 1 18 439 1 19 438 1 ...
result:
ok good.
Test #19:
score: 0
Accepted
time: 11ms
memory: 4908kb
input:
455
output:
103285 1 2 455 1 3 454 1 4 453 1 5 452 1 6 451 1 7 450 1 8 449 1 9 448 1 10 447 1 11 446 1 12 445 1 13 444 1 14 443 1 15 442 1 16 441 1 17 440 1 18 439 1 19 438 1 20 437 1 21 436 1 22 435 1 23 434 1 24 433 1 25 432 1 26 431 1 27 430 1 28 429 1 29 428 1 30 427 1 31 426 1 32 425 1 33 424 1 34 423 1 35...
result:
ok good.
Test #20:
score: 0
Accepted
time: 18ms
memory: 6292kb
input:
478
output:
228006 1 2 477 1 3 476 1 3 476 1 4 475 1 4 475 1 5 474 1 5 474 1 6 473 1 6 473 1 7 472 1 7 472 1 8 471 1 8 471 1 9 470 1 9 470 1 10 469 1 10 469 1 11 468 1 11 468 1 12 467 1 12 467 1 13 466 1 13 466 1 14 465 1 14 465 1 15 464 1 15 464 1 16 463 1 16 463 1 17 462 1 17 462 1 18 461 1 18 461 1 19 460 1 ...
result:
ok good.
Test #21:
score: 0
Accepted
time: 39ms
memory: 9948kb
input:
945
output:
446040 1 2 945 1 3 944 1 4 943 1 5 942 1 6 941 1 7 940 1 8 939 1 9 938 1 10 937 1 11 936 1 12 935 1 13 934 1 14 933 1 15 932 1 16 931 1 17 930 1 18 929 1 19 928 1 20 927 1 21 926 1 22 925 1 23 924 1 24 923 1 25 922 1 26 921 1 27 920 1 28 919 1 29 918 1 30 917 1 31 916 1 32 915 1 33 914 1 34 913 1 35...
result:
ok good.
Test #22:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
177
output:
15576 1 2 177 1 3 176 1 4 175 1 5 174 1 6 173 1 7 172 1 8 171 1 9 170 1 10 169 1 11 168 1 12 167 1 13 166 1 14 165 1 15 164 1 16 163 1 17 162 1 18 161 1 19 160 1 20 159 1 21 158 1 22 157 1 23 156 1 24 155 1 25 154 1 26 153 1 27 152 1 28 151 1 29 150 1 30 149 1 31 148 1 32 147 1 33 146 1 34 145 1 35 ...
result:
ok good.
Test #23:
score: 0
Accepted
time: 3ms
memory: 3864kb
input:
233
output:
27028 1 2 233 1 3 232 1 4 231 1 5 230 1 6 229 1 7 228 1 8 227 1 9 226 1 10 225 1 11 224 1 12 223 1 13 222 1 14 221 1 15 220 1 16 219 1 17 218 1 18 217 1 19 216 1 20 215 1 21 214 1 22 213 1 23 212 1 24 211 1 25 210 1 26 209 1 27 208 1 28 207 1 29 206 1 30 205 1 31 204 1 32 203 1 33 202 1 34 201 1 35 ...
result:
ok good.
Test #24:
score: 0
Accepted
time: 3ms
memory: 4780kb
input:
387
output:
74691 1 2 387 1 3 386 1 4 385 1 5 384 1 6 383 1 7 382 1 8 381 1 9 380 1 10 379 1 11 378 1 12 377 1 13 376 1 14 375 1 15 374 1 16 373 1 17 372 1 18 371 1 19 370 1 20 369 1 21 368 1 22 367 1 23 366 1 24 365 1 25 364 1 26 363 1 27 362 1 28 361 1 29 360 1 30 359 1 31 358 1 32 357 1 33 356 1 34 355 1 35 ...
result:
ok good.
Test #25:
score: 0
Accepted
time: 21ms
memory: 10844kb
input:
516
output:
265740 1 2 515 1 3 514 1 3 514 1 4 513 1 4 513 1 5 512 1 5 512 1 6 511 1 6 511 1 7 510 1 7 510 1 8 509 1 8 509 1 9 508 1 9 508 1 10 507 1 10 507 1 11 506 1 11 506 1 12 505 1 12 505 1 13 504 1 13 504 1 14 503 1 14 503 1 15 502 1 15 502 1 16 501 1 16 501 1 17 500 1 17 500 1 18 499 1 18 499 1 19 498 1 ...
result:
ok good.