QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#68150 | #5095. 九王唱 | lmeowdn | 20 | 3ms | 5804kb | C++20 | 1.4kb | 2022-12-14 20:05:54 | 2022-12-14 20:05:57 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define fi first
#define se second
#define eb emplace_back
#define bp __builtin_parity
#define y1 yyl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef bitset<1009> bset;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
return x*w;
}
const int N=5009;
int b[N][N],a[N][N],n,seed;
int lst(int x) {return x==1?n:x-1;}
void gen(int n,int seed){
std::mt19937 rnd(seed);
for(int i=1;i<=n;++i){
for(int j=1;j<=n+1;++j){
a[i][j]=j;
std::swap(a[i][j],a[i][rnd()%j+1]);
}
}
}
void work(int p) {
for(int x=lst(p);;x=lst(x)) {
int p1=0, p2=0, rc=0;
rep(i,1,n+1) {
if(b[x][i]==1) p1=i;
else if(b[x][i]==2) p2=i;
}
for(int y=lst(x);y!=lst(p);y=lst(y)) {
rep(j,1,n+1) {
if(b[y][j]>b[y][p1]) b[y][j]--;
}
b[y][p1]=0;
}
if(x==p) {
printf("%d ",p2);
return;
}
}
}
signed main() {
n=read(), seed=read();
if(seed) gen(n,seed);
else rep(i,1,n) rep(j,1,n+1) a[i][j]=read();
rep(i,1,n) {
rep(j,1,n) rep(k,1,n+1) b[j][k]=a[j][k];
work(i);
} putchar('\n');
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 8
Accepted
Test #1:
score: 8
Accepted
time: 3ms
memory: 5532kb
input:
8 0 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5 6 1 3 2 9 7 8 4 5
output:
5 5 5 5 5 5 5 5
result:
ok 8 numbers
Test #2:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
8 0 4 7 8 6 1 3 2 9 5 5 8 9 7 2 4 3 1 6 6 9 1 8 3 5 4 2 7 7 1 2 9 4 6 5 3 8 8 2 3 1 5 7 6 4 9 9 3 4 2 6 8 7 5 1 1 4 5 3 7 9 8 6 2 2 5 6 4 8 1 9 7 3
output:
7 7 7 7 7 7 7 7
result:
ok 8 numbers
Test #3:
score: 0
Accepted
time: 2ms
memory: 3788kb
input:
8 0 5 2 6 8 7 9 1 3 4 4 1 5 7 6 8 9 2 3 3 9 4 6 5 7 8 1 2 2 8 3 5 4 6 7 9 1 1 7 2 4 3 5 6 8 9 9 6 1 3 2 4 5 7 8 8 5 9 2 1 3 4 6 7 7 4 8 1 9 2 3 5 6
output:
6 6 6 6 6 6 6 6
result:
ok 8 numbers
Test #4:
score: 0
Accepted
time: 2ms
memory: 3576kb
input:
8 0 2 3 9 1 5 7 6 4 8 2 3 9 1 6 8 7 4 5 2 3 9 1 4 8 6 5 7 2 3 9 1 8 4 5 6 7 2 3 9 1 8 6 7 5 4 2 3 9 1 6 4 7 8 5 2 3 9 1 4 6 5 7 8 2 3 9 1 7 8 5 6 4
output:
3 3 3 3 3 3 3 3
result:
ok 8 numbers
Test #5:
score: 0
Accepted
time: 2ms
memory: 3672kb
input:
7 0 8 1 5 4 7 6 3 2 8 1 5 7 2 6 4 3 8 1 5 2 7 3 4 6 8 1 5 3 6 7 2 4 8 1 5 4 6 7 2 3 8 1 5 3 7 4 2 6 8 1 5 4 3 2 6 7
output:
1 1 1 1 1 1 1
result:
ok 7 numbers
Test #6:
score: 0
Accepted
time: 3ms
memory: 3752kb
input:
8 0 2 7 8 1 5 6 3 9 4 9 5 6 1 4 3 8 2 7 4 1 8 3 5 7 2 9 6 6 2 5 8 1 9 7 4 3 4 7 2 5 8 9 1 3 6 3 4 8 2 9 5 7 1 6 7 2 9 1 3 8 5 4 6 5 6 8 3 4 7 9 2 1
output:
3 3 3 6 3 3 3 3
result:
ok 8 numbers
Test #7:
score: 0
Accepted
time: 2ms
memory: 3572kb
input:
8 0 4 5 2 3 7 8 6 1 9 6 2 4 8 7 5 9 3 1 5 2 3 4 6 1 9 8 7 3 4 6 9 1 8 5 2 7 4 9 1 3 8 6 7 5 2 8 5 3 1 4 2 6 9 7 8 6 7 2 3 9 4 5 1 1 3 9 6 7 8 4 5 2
output:
7 7 7 2 2 7 2 7
result:
ok 8 numbers
Test #8:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
7 0 7 4 2 3 8 6 5 1 7 2 6 5 1 8 3 4 1 4 3 8 2 7 6 5 1 4 8 6 2 3 5 7 6 4 3 8 2 5 1 7 2 3 8 6 4 5 7 1 5 6 7 2 8 3 1 4
output:
6 4 4 4 4 3 6
result:
ok 7 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 3748kb
input:
7 0 1 5 6 4 8 7 2 3 4 3 5 2 8 1 7 6 7 5 6 2 3 1 4 8 3 6 7 4 2 5 1 8 6 4 3 8 7 2 5 1 5 4 3 6 7 8 1 2 6 3 7 8 1 5 4 2
output:
3 3 3 3 2 2 3
result:
ok 7 numbers
Subtask #2:
score: 12
Accepted
Dependency #1:
100%
Accepted
Test #10:
score: 12
Accepted
time: 2ms
memory: 3816kb
input:
16 0 4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8 4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8 4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8 4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8 4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8 4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8 4 16 10 6 15 11 2 1 7 9 13 17 3 5 12 14 8 4...
output:
12 12 12 12 12 12 12 12 12 12 12 12 12 12 12 12
result:
ok 16 numbers
Test #11:
score: 0
Accepted
time: 3ms
memory: 3792kb
input:
13 0 1 11 2 10 14 5 7 4 12 13 3 8 9 6 1 11 2 10 14 5 13 3 12 9 8 4 7 6 1 11 2 10 14 5 7 6 9 3 8 12 13 4 1 11 2 10 14 5 12 13 4 3 8 7 9 6 1 11 2 10 14 5 13 9 4 7 8 12 6 3 1 11 2 10 14 5 7 8 12 13 3 6 9 4 1 11 2 10 14 5 3 4 13 9 6 12 8 7 1 11 2 10 14 5 3 6 13 8 4 12 9 7 1 11 2 10 14 5 4 13 7 12 9 6 3 ...
output:
5 5 5 5 5 5 5 5 5 5 5 5 5
result:
ok 13 numbers
Test #12:
score: 0
Accepted
time: 2ms
memory: 3580kb
input:
16 0 2 7 17 3 1 14 15 13 8 11 6 5 10 16 9 4 12 5 9 13 12 6 16 7 1 3 2 14 17 11 10 4 15 8 1 17 6 10 3 8 11 7 15 5 14 13 16 9 2 12 4 10 4 7 1 14 9 15 3 6 8 13 11 5 17 16 2 12 16 6 14 15 1 7 5 17 8 12 10 13 4 3 11 2 9 6 2 3 11 12 7 14 4 15 5 17 16 8 9 10 1 13 12 9 1 3 4 10 15 16 6 11 7 5 13 17 8 2 14 1...
output:
17 17 15 15 15 13 13 13 10 15 10 10 14 14 14 14
result:
ok 16 numbers
Test #13:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
16 0 2 11 13 12 15 9 4 17 10 16 5 1 3 8 7 6 14 15 3 16 5 10 1 13 9 4 14 6 11 17 7 2 12 8 5 6 2 7 14 3 16 10 13 8 9 1 4 11 17 15 12 11 17 12 14 6 2 4 8 16 3 1 9 13 5 10 7 15 7 12 5 8 2 11 4 15 1 13 17 9 3 16 14 6 10 8 13 1 7 12 4 11 14 15 2 16 10 5 9 6 17 3 8 5 14 1 9 6 11 17 7 13 2 4 16 12 15 3 10 1...
output:
8 8 8 2 8 8 8 8 8 8 8 2 2 7 16 8
result:
ok 16 numbers
Test #14:
score: 0
Accepted
time: 2ms
memory: 3844kb
input:
15 0 16 9 10 14 4 12 11 13 3 1 5 15 7 2 8 6 9 7 11 16 2 1 10 8 3 15 13 6 14 5 12 4 10 8 12 9 5 7 1 3 14 2 11 15 6 4 16 13 10 8 9 2 1 16 14 5 15 6 7 4 13 12 3 11 16 11 10 1 12 14 3 15 2 4 5 6 8 9 7 13 4 15 14 2 9 6 8 3 11 1 12 10 16 5 7 13 13 14 8 5 1 3 7 9 16 10 12 6 4 2 11 15 6 15 11 13 2 5 12 10 9...
output:
3 3 16 16 16 11 9 9 11 3 3 11 3 3 3
result:
ok 15 numbers
Test #15:
score: 0
Accepted
time: 2ms
memory: 3568kb
input:
15 0 12 4 2 8 5 16 6 14 13 11 10 1 9 3 7 15 3 6 14 4 12 5 1 9 13 7 2 8 15 10 16 11 13 3 11 1 12 6 16 14 4 2 9 7 15 10 8 5 4 6 15 1 16 8 2 10 5 12 14 7 9 11 13 3 9 5 4 6 10 2 3 7 13 1 15 11 8 12 16 14 11 13 9 10 6 3 7 5 8 12 15 4 1 16 14 2 15 5 2 4 7 10 3 16 6 14 1 13 11 12 8 9 15 3 1 4 7 9 11 6 16 1...
output:
8 14 8 14 14 14 14 6 6 14 6 6 14 14 14
result:
ok 15 numbers
Test #16:
score: 0
Accepted
time: 2ms
memory: 3728kb
input:
14 0 15 2 3 14 12 8 4 7 9 1 10 6 13 11 5 8 14 2 15 11 5 3 9 4 10 7 13 12 1 6 4 14 15 9 5 13 1 6 10 2 3 11 8 12 7 4 1 9 15 11 14 2 3 12 7 10 13 6 5 8 14 2 15 8 1 11 12 6 13 10 7 4 3 9 5 3 10 2 12 8 14 1 7 9 4 6 11 5 13 15 8 3 14 15 13 6 1 11 5 4 12 10 2 9 7 13 8 10 5 9 14 12 4 7 3 6 11 15 2 1 13 8 2 ...
output:
11 8 9 9 11 11 1 1 9 11 1 11 11 11
result:
ok 14 numbers
Test #17:
score: 0
Accepted
time: 2ms
memory: 3564kb
input:
14 0 11 9 15 1 6 7 10 8 5 14 13 3 4 12 2 8 15 14 1 3 6 12 10 11 7 13 5 4 9 2 13 4 11 6 12 1 15 9 3 14 7 5 10 8 2 5 12 4 9 2 3 1 15 10 13 6 14 7 11 8 7 14 15 6 3 10 12 11 2 1 8 5 4 9 13 12 8 11 9 15 13 6 14 3 10 4 7 2 5 1 12 14 3 7 2 13 10 6 15 5 1 9 11 4 8 14 6 3 4 7 5 1 13 15 12 10 9 2 8 11 2 15 14...
output:
3 3 3 8 3 8 8 8 3 8 8 8 8 3
result:
ok 14 numbers
Test #18:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
13 0 3 5 14 4 7 2 10 12 11 9 8 6 13 1 13 1 14 3 4 7 2 10 12 9 11 5 8 6 6 13 1 12 7 8 11 2 14 9 10 4 3 5 4 11 8 7 9 2 12 6 10 1 13 5 3 14 12 6 7 14 1 11 5 2 13 9 10 8 4 3 8 7 4 9 2 12 3 13 5 1 14 10 6 11 8 3 4 10 9 1 5 12 11 7 14 6 13 2 10 6 7 2 8 4 11 1 9 12 3 13 14 5 13 8 5 7 10 1 2 11 14 4 3 12 6 ...
output:
11 11 4 11 4 11 11 4 4 4 4 4 11
result:
ok 13 numbers
Test #19:
score: 0
Accepted
time: 2ms
memory: 3700kb
input:
13 0 2 8 3 6 12 9 11 10 5 13 7 1 4 14 6 13 1 14 7 2 9 8 3 11 10 4 5 12 14 6 10 1 8 5 3 7 9 12 11 4 13 2 12 5 1 8 6 7 9 11 4 3 10 13 2 14 5 11 3 14 2 12 4 7 9 6 10 13 8 1 12 6 11 9 5 10 1 13 14 3 7 4 2 8 1 14 10 2 13 11 6 8 3 7 9 4 12 5 2 7 13 10 4 14 3 12 5 9 6 11 8 1 5 4 6 7 10 1 3 9 12 2 13 14 8 1...
output:
2 11 11 11 11 11 11 8 11 11 11 10 10
result:
ok 13 numbers
Test #20:
score: 0
Accepted
time: 2ms
memory: 3636kb
input:
15 0 4 7 10 6 3 11 16 1 15 2 8 12 9 5 13 14 4 7 10 6 3 11 16 1 15 2 8 12 9 5 13 14 4 7 10 6 3 11 16 1 15 2 8 12 9 5 13 14 4 7 10 6 3 11 16 1 15 2 8 12 9 5 13 14 4 7 10 6 3 11 16 1 15 2 8 12 9 5 13 14 4 7 10 6 3 11 16 1 15 2 8 12 9 5 13 14 4 7 10 6 3 11 16 1 15 2 8 12 9 5 13 14 4 7 10 6 3 11 16 1 15 ...
output:
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
result:
ok 15 numbers
Test #21:
score: 0
Accepted
time: 2ms
memory: 3928kb
input:
16 0 14 1 16 7 10 12 11 2 17 8 4 5 15 13 3 9 6 15 2 17 8 11 13 12 3 1 9 5 6 16 14 4 10 7 16 3 1 9 12 14 13 4 2 10 6 7 17 15 5 11 8 17 4 2 10 13 15 14 5 3 11 7 8 1 16 6 12 9 1 5 3 11 14 16 15 6 4 12 8 9 2 17 7 13 10 2 6 4 12 15 17 16 7 5 13 9 10 3 1 8 14 11 3 7 5 13 16 1 17 8 6 14 10 11 4 2 9 15 12 4...
output:
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
result:
ok 16 numbers
Test #22:
score: 0
Accepted
time: 2ms
memory: 3736kb
input:
15 0 5 7 16 4 14 9 15 8 3 6 13 12 11 10 2 1 6 8 1 5 15 10 16 9 4 7 14 13 12 11 3 2 7 9 2 6 16 11 1 10 5 8 15 14 13 12 4 3 8 10 3 7 1 12 2 11 6 9 16 15 14 13 5 4 9 11 4 8 2 13 3 12 7 10 1 16 15 14 6 5 10 12 5 9 3 14 4 13 8 11 2 1 16 15 7 6 11 13 6 10 4 15 5 14 9 12 3 2 1 16 8 7 12 14 7 11 5 16 6 15 1...
output:
15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
result:
ok 15 numbers
Test #23:
score: 0
Accepted
time: 3ms
memory: 5624kb
input:
16 0 12 6 14 5 1 3 2 13 16 8 11 4 7 10 17 9 15 11 5 13 4 17 2 1 12 15 7 10 3 6 9 16 8 14 10 4 12 3 16 1 17 11 14 6 9 2 5 8 15 7 13 9 3 11 2 15 17 16 10 13 5 8 1 4 7 14 6 12 8 2 10 1 14 16 15 9 12 4 7 17 3 6 13 5 11 7 1 9 17 13 15 14 8 11 3 6 16 2 5 12 4 10 6 17 8 16 12 14 13 7 10 2 5 15 1 4 11 3 9 5...
output:
15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15
result:
ok 16 numbers
Test #24:
score: 0
Accepted
time: 3ms
memory: 5588kb
input:
15 0 9 12 15 2 8 3 11 13 1 14 5 7 16 6 10 4 8 11 14 1 7 2 10 12 16 13 4 6 15 5 9 3 7 10 13 16 6 1 9 11 15 12 3 5 14 4 8 2 6 9 12 15 5 16 8 10 14 11 2 4 13 3 7 1 5 8 11 14 4 15 7 9 13 10 1 3 12 2 6 16 4 7 10 13 3 14 6 8 12 9 16 2 11 1 5 15 3 6 9 12 2 13 5 7 11 8 15 1 10 16 4 14 2 5 8 11 1 12 4 6 10 7...
output:
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13
result:
ok 15 numbers
Test #25:
score: 0
Accepted
time: 3ms
memory: 5804kb
input:
16 0 5 3 2 10 14 7 16 8 15 12 6 4 13 9 1 17 11 5 3 2 10 14 7 16 8 4 6 17 12 9 1 13 11 15 5 3 2 10 14 7 16 8 17 6 4 1 11 12 9 15 13 5 3 2 10 14 7 16 8 6 4 17 9 13 12 15 11 1 5 3 2 10 14 7 16 8 9 4 6 13 15 11 12 17 1 5 3 2 10 14 7 16 8 13 12 1 9 6 17 4 11 15 5 3 2 10 14 7 16 8 1 4 9 13 6 17 15 12 11 5...
output:
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
result:
ok 16 numbers
Test #26:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
15 0 2 3 5 16 1 6 13 15 12 7 10 8 14 11 4 9 2 3 5 16 1 6 13 9 10 15 8 14 7 11 12 4 2 3 5 16 1 6 13 4 11 10 12 7 15 9 14 8 2 3 5 16 1 6 13 11 12 8 14 7 15 10 9 4 2 3 5 16 1 6 13 14 15 9 8 4 12 7 11 10 2 3 5 16 1 6 13 4 15 14 7 8 12 10 9 11 2 3 5 16 1 6 13 9 11 10 14 15 12 4 8 7 2 3 5 16 1 6 13 8 4 10...
output:
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
result:
ok 15 numbers
Test #27:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
14 0 9 5 1 8 6 7 11 13 12 2 4 3 15 10 14 9 5 1 8 6 7 11 4 12 3 15 10 14 2 13 9 5 1 8 6 7 11 4 14 10 15 12 13 3 2 9 5 1 8 6 7 11 3 12 13 10 15 14 2 4 9 5 1 8 6 7 11 3 13 4 10 15 14 12 2 9 5 1 8 6 7 11 14 12 15 13 4 3 2 10 9 5 1 8 6 7 11 15 13 14 4 3 10 12 2 9 5 1 8 6 7 11 14 13 15 3 10 2 4 12 9 5 1 8...
output:
9 9 9 9 9 9 9 9 9 9 9 9 9 7
result:
ok 14 numbers
Subtask #3:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #28:
score: 0
Time Limit Exceeded
input:
500 0 266 145 487 131 455 391 450 208 437 316 251 482 14 324 72 167 79 243 462 315 466 207 39 16 446 29 245 483 320 260 449 317 399 469 98 423 46 353 322 313 367 355 201 47 250 38 143 6 83 225 51 183 184 280 209 137 459 390 96 198 138 308 276 100 265 48 15 27 246 129 152 99 285 311 118 385 447 475 2...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
0%