QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722809#1873. ArrayMade_in_CodeWA 0ms5632kbC++141.2kb2024-11-07 20:14:332024-11-07 20:14:36

Judging History

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

  • [2024-11-07 20:14:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:5632kb
  • [2024-11-07 20:14:33]
  • 提交

answer

#include <iostream>

using namespace std;

const int kMaxN = 5e5 + 1;
int t, n, m, k, a[kMaxN], b[kMaxN];

void Solve() {
  cin >> n, m = n, k = 1;
  for (int i = 1; i <= n; i++) {
    cin >> a[i], b[i] = 0;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] <= n) {
      m = min(m, a[i] - i + 1);
    }
    if (a[i] < i || a[i] < a[i - 1]) {
      cout << "NO\n";
      return;
    }
  }
  if (a[1] == n + 1) {
    cout << "NO\n";
    return;
  }
  for (int i = 1; i < m; i++) {
    b[i] = i;
  }
  b[a[1]] = m;
  for (int i = 1; i < n; i++) {
    for (; k <= n && b[k]; k++) {
    }
    if (!b[i]) {
      cout << "NO\n";
      return;
    } else if (a[i] == a[i + 1]) {
      b[k] = b[i];
    } else if (a[i + 1] <= n) {
      b[a[i + 1]] = b[i];
    } else if (i + 1 == k) {
      cout << "NO\n";
      return;
    } else {
      break;
    }
  }
  for (; k <= n; k++) {
    !b[k] && (b[k] = b[k - 1]);
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    cout << b[i] << " \n"[i == n];
  }
}

int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(0);
  cin >> t;
  while (t--) {
    Solve();
  }
  return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 5632kb

input:

3
4
3 3 5 5
7
4 6 6 7 8 8 8
5
2 3 4 4 6

output:

YES
1 1 2 2
YES
1 2 3 4 2 1 3
NO

result:

wrong output format Expected integer, but "YES" found