QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#353426 | #7263. Team Competition | Naganohara_Yoimiya | AC ✓ | 137ms | 15516kb | C++14 | 1.5kb | 2024-03-14 08:48:30 | 2024-03-14 08:48:30 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define mk make_pair
#define fi first
#define se second
using namespace std;
inline 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&15);
return x*f;
}
const int mod=998244353;
int ksm(int x,ll y,int p=mod){
int ans=1;y%=(p-1);
for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
int cmod(int x){if(x>=mod)x-=mod;return x;}
template<typename T>void cmax(T &x,T v){x=max(x,v);}
template<typename T>void cmin(T &x,T v){x=min(x,v);}
struct Node{int x,y,z;Node(int X=0,int Y=0,int Z=0):x(X),y(Y),z(Z){}};
void solve(){
vector<Node>ans;
auto op=[&](int x,int y,int z){ans.emplace_back(Node(x,y,z));};
int n=read();
if(n&1){
for(int i=0;i<n;i++)for(int d=1;d<=(n-1)/2;d++)op(i,(i+d)%n,(i-d+n)%n);
}
else{
n--;
for(int i=0;i<n;i++)for(int d=1;d<=(n-1)/2;d++)op(i,(i+d)%n,(i-d+n)%n);
for(int i=0;i<n;i++)for(int d=2;d<=(n-1)/2;d++)op(i,(i+d)%n,(i-d+n)%n);
for(int i=0;i<n;i++)op(i,(i+1)%n,n),op(i,(i+1)%n,n),op(i,(i+2)%n,n);
}
cout<<ans.size()<<'\n';
for(auto [x,y,z]:ans)cout<<x+1<<" "<<y+1<<" "<<z+1<<'\n';
}
signed main(void){
int tt=1;while(tt--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3872kb
input:
5
output:
10 1 2 5 1 3 4 2 3 1 2 4 5 3 4 2 3 5 1 4 5 3 4 1 2 5 1 4 5 2 3
result:
ok good.
Test #2:
score: 0
Accepted
time: 57ms
memory: 9404kb
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: 110ms
memory: 15516kb
input:
996
output:
991020 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 #4:
score: 0
Accepted
time: 64ms
memory: 9332kb
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: 137ms
memory: 15516kb
input:
998
output:
995006 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 #6:
score: 0
Accepted
time: 59ms
memory: 9440kb
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: 128ms
memory: 15492kb
input:
1000
output:
999000 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 #8:
score: 0
Accepted
time: 1ms
memory: 3620kb
input:
3
output:
3 1 2 3 2 3 1 3 1 2
result:
ok good.
Test #9:
score: 0
Accepted
time: 1ms
memory: 3588kb
input:
4
output:
12 1 2 3 2 3 1 3 1 2 1 2 4 1 2 4 1 3 4 2 3 4 2 3 4 2 1 4 3 1 4 3 1 4 3 2 4
result:
ok good.
Test #10:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
5
output:
10 1 2 5 1 3 4 2 3 1 2 4 5 3 4 2 3 5 1 4 5 3 4 1 2 5 1 4 5 2 3
result:
ok good.
Test #11:
score: 0
Accepted
time: 1ms
memory: 3652kb
input:
6
output:
30 1 2 5 1 3 4 2 3 1 2 4 5 3 4 2 3 5 1 4 5 3 4 1 2 5 1 4 5 2 3 1 3 4 2 4 5 3 5 1 4 1 2 5 2 3 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 4 1 6 5 1 6 5 1 6 5 2 6
result:
ok good.
Test #12:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
7
output:
21 1 2 7 1 3 6 1 4 5 2 3 1 2 4 7 2 5 6 3 4 2 3 5 1 3 6 7 4 5 3 4 6 2 4 7 1 5 6 4 5 7 3 5 1 2 6 7 5 6 1 4 6 2 3 7 1 6 7 2 5 7 3 4
result:
ok good.
Test #13:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
8
output:
56 1 2 7 1 3 6 1 4 5 2 3 1 2 4 7 2 5 6 3 4 2 3 5 1 3 6 7 4 5 3 4 6 2 4 7 1 5 6 4 5 7 3 5 1 2 6 7 5 6 1 4 6 2 3 7 1 6 7 2 5 7 3 4 1 3 6 1 4 5 2 4 7 2 5 6 3 5 1 3 6 7 4 6 2 4 7 1 5 7 3 5 1 2 6 1 4 6 2 3 7 2 5 7 3 4 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: 1ms
memory: 3664kb
input:
9
output:
36 1 2 9 1 3 8 1 4 7 1 5 6 2 3 1 2 4 9 2 5 8 2 6 7 3 4 2 3 5 1 3 6 9 3 7 8 4 5 3 4 6 2 4 7 1 4 8 9 5 6 4 5 7 3 5 8 2 5 9 1 6 7 5 6 8 4 6 9 3 6 1 2 7 8 6 7 9 5 7 1 4 7 2 3 8 9 7 8 1 6 8 2 5 8 3 4 9 1 8 9 2 7 9 3 6 9 4 5
result:
ok good.
Test #15:
score: 0
Accepted
time: 1ms
memory: 3900kb
input:
10
output:
90 1 2 9 1 3 8 1 4 7 1 5 6 2 3 1 2 4 9 2 5 8 2 6 7 3 4 2 3 5 1 3 6 9 3 7 8 4 5 3 4 6 2 4 7 1 4 8 9 5 6 4 5 7 3 5 8 2 5 9 1 6 7 5 6 8 4 6 9 3 6 1 2 7 8 6 7 9 5 7 1 4 7 2 3 8 9 7 8 1 6 8 2 5 8 3 4 9 1 8 9 2 7 9 3 6 9 4 5 1 3 8 1 4 7 1 5 6 2 4 9 2 5 8 2 6 7 3 5 1 3 6 9 3 7 8 4 6 2 4 7 1 4 8 9 5 7 3 5 8...
result:
ok good.
Test #16:
score: 0
Accepted
time: 123ms
memory: 15352kb
input:
974
output:
947702 1 2 973 1 3 972 1 4 971 1 5 970 1 6 969 1 7 968 1 8 967 1 9 966 1 10 965 1 11 964 1 12 963 1 13 962 1 14 961 1 15 960 1 16 959 1 17 958 1 18 957 1 19 956 1 20 955 1 21 954 1 22 953 1 23 952 1 24 951 1 25 950 1 26 949 1 27 948 1 28 947 1 29 946 1 30 945 1 31 944 1 32 943 1 33 942 1 34 941 1 35...
result:
ok good.
Test #17:
score: 0
Accepted
time: 0ms
memory: 3980kb
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: 26ms
memory: 6420kb
input:
456
output:
207480 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 #19:
score: 0
Accepted
time: 13ms
memory: 4820kb
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: 30ms
memory: 6340kb
input:
478
output:
228006 1 2 477 1 3 476 1 4 475 1 5 474 1 6 473 1 7 472 1 8 471 1 9 470 1 10 469 1 11 468 1 12 467 1 13 466 1 14 465 1 15 464 1 16 463 1 17 462 1 18 461 1 19 460 1 20 459 1 21 458 1 22 457 1 23 456 1 24 455 1 25 454 1 26 453 1 27 452 1 28 451 1 29 450 1 30 449 1 31 448 1 32 447 1 33 446 1 34 445 1 35...
result:
ok good.
Test #21:
score: 0
Accepted
time: 54ms
memory: 9488kb
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: 3ms
memory: 3788kb
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: 2ms
memory: 3944kb
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: 8ms
memory: 4908kb
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: 36ms
memory: 9468kb
input:
516
output:
265740 1 2 515 1 3 514 1 4 513 1 5 512 1 6 511 1 7 510 1 8 509 1 9 508 1 10 507 1 11 506 1 12 505 1 13 504 1 14 503 1 15 502 1 16 501 1 17 500 1 18 499 1 19 498 1 20 497 1 21 496 1 22 495 1 23 494 1 24 493 1 25 492 1 26 491 1 27 490 1 28 489 1 29 488 1 30 487 1 31 486 1 32 485 1 33 484 1 34 483 1 35...
result:
ok good.