QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#369704 | #5095. 九王唱 | zyc070419 | 0 | 1ms | 3828kb | C++20 | 1.1kb | 2024-03-28 16:48:09 | 2024-03-28 16:48:10 |
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
inline int read() {
char ch = getchar(); int x = 0;
while (!isdigit(ch)) {ch = getchar();};
while (isdigit(ch)) {x = x * 10 + ch - 48; ch = getchar();}
return x;
}
int a[N][N];
void gen(int n, int seed) {
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 n, seed;
bool vis[N];
int main() {
n = read(); seed = read();
if (seed) gen(n, seed);
else {
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n + 1; ++j)
a[i][j] = read();
}
for (int p = 1; p <= n; ++p) {
for (int ans = n + 1; ans >= 1; --ans) {
for (int i = 1; i <= n + 1; ++i) vis[i] = false;
int cnt = 1; bool pd = true;
for (int i = 1, x = p + 1; i < n; ++i, ++x) {
if (x > n) x -= n;
for (int j = n + 1;; --j) {
if (a[x][j] == a[p][ans]) break;
if (!vis[a[x][j]]) cnt--, vis[a[x][j]] = true;
}
if (cnt < 0) {pd = false; break;}
cnt++;
}
if (pd) {printf("%d ", a[p][ans]); break;}
}
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 1ms
memory: 3828kb
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
Wrong Answer
time: 0ms
memory: 3564kb
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:
result:
wrong answer Answer contains longer sequence [length = 8], but output contains 0 elements
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%