QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#266388 | #6638. Treelection | Hongzy | WA | 0ms | 3944kb | C++17 | 904b | 2023-11-26 13:36:11 | 2023-11-26 13:36:11 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;
using ll = long long;
const int N = 20;
int n, b[N], a[N];
int main() {
int test;
scanf("%d", &test);
rep(T, 1, test) {
scanf("%d", &n);
rep(i, 1, n) scanf("%d", b + i);
bool ok = true;
b[0] = 0;
rep(i, 0, n - 1) ok &= b[i+1] == b[i] || b[i+1] == b[i]+1;
if(!ok) {
puts("NO");
continue;
}
puts("YES");
int v = 0;
for(int i = 1, j; i <= n; i = j + 1) {
j = i;
while(j < n && b[j+1] == b[j]) ++j;
for(int k = j; k >= i; k --) {
a[k] = ++v;
}
}
rep(i, 1, n)
printf("%d%c", a[i], " \n"[i == n]);
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3944kb
input:
2 4 1 2 3 5 1 1 2 2
output:
NO YES 1
result:
wrong answer 1st lines differ - expected: '1100', found: 'NO'