QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#545770 | #5095. 九王唱 | kintsgi | 0 | 1ms | 5972kb | C++14 | 1.6kb | 2024-09-03 17:06:46 | 2024-09-03 17:06:47 |
answer
#include <bits/stdc++.h>
#define PR(x) printf(x ? "YES\n" : "NO\n")
#define pr(x) printf(x ? "Yes\n" : "No\n")
#define mk make_pair
#define pb emplace_back
#define fi first
#define se second
#define pii pair<int, int>
#define fore(i, u, v) for (int i = h[u], v = e[i].v; i; v = e[i = e[i].nxt].v)
#define all(x) x.begin(), x.end()
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
while (! isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); }
return x * f;
}
const int maxn = 5e3 + 10;
int n, seed, w[maxn], id[maxn];
bool vi[maxn]; int a[maxn][maxn], b[maxn][maxn];
void gen(){
mt19937 rnd(seed);
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= n + 1; j ++)
a[i][j] = j, swap(a[i][j], a[i][rnd() % j + 1]);
}
int main() {
n = read(), seed = read();
if (!seed) {
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= n + 1; j ++) a[i][j] = read();
} else gen();
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= n + 1; j ++) b[i][a[i][j]] = j;
for (int i = n; i; i --) {
w[i] = 1;
while (vi[b[i][w[i]]]) w[i] ++;
vi[b[i][w[i]]] = 1;
}
for (int i = 1; i <= n; i ++) id[i] = i;
for (int i = 1; i <= n; i ++) {
int t = 1; while (vi[t]) t ++;
printf("%d ", t);
int p = id[1];
rotate(id + 1, id + 2, id + n + 1);
fill(vi + 1, vi + n + 2, 0);
vi[b[p][w[p] = 1]] = 1;
for (int j = 1; j < n; j ++) {
p = id[j];
while (vi[b[p][w[p]]]) w[p] ++;
vi[b[p][w[p]]] = 1;
}
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 1ms
memory: 5868kb
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: 8
Accepted
time: 0ms
memory: 5868kb
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: 8
Accepted
time: 0ms
memory: 5868kb
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: 8
Accepted
time: 0ms
memory: 5972kb
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: 8
Accepted
time: 0ms
memory: 5964kb
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
Wrong Answer
time: 1ms
memory: 5920kb
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 3 3 3 3 3
result:
wrong answer 4th numbers differ - expected: '6', found: '3'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%