QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#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;
}
Details
Tip: Click on the bar to expand more detailed information
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'