QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#266388#6638. TreelectionHongzyWA 0ms3944kbC++17904b2023-11-26 13:36:112023-11-26 13:36:11

Judging History

你现在查看的是最新测评结果

  • [2023-11-26 13:36:11]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3944kb
  • [2023-11-26 13:36:11]
  • 提交

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'