Submission #69760179


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector<vector<ll>> Mat;
#define fi first
#define se second
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);
void yes() { printf("yes\n"); }
void no() { printf("no\n"); }
void Yes() { printf("Yes\n"); }
void No() { printf("No\n"); }
void YES() { printf("YES\n"); }
void NO() { printf("NO\n"); }

int n, a[15];
int cnt[15], p[15];

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] != -1) {
      cnt[a[i]]++;
      p[i] = a[i];
    }
  }

  for (int i = 1; i <= n; i++) {
    if (cnt[i] >= 2) {
      No();
      return 0;
    }
  }

  Yes();
  int now = 1;
  for (int i = 1; i <= n; i++) {
    while (cnt[now] > 0) {
      now++;
    }

    if (p[i] == 0) {
      p[i] = now;
      now++;
    }
  }

  for (int i = 1; i <= n; i++) {
    cout << p[i] << (i == n ? '\n' : ' ');
  }

  return 0;
}

Submission Info

Submission Time
Task B - Find Permutation 2
User yutas
Language C++ 20 (gcc 12.2)
Score 200
Code Size 1192 Byte
Status AC
Exec Time 1 ms
Memory 3672 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 32
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_Yes_00.txt, 01_Yes_01.txt, 01_Yes_02.txt, 01_Yes_03.txt, 01_Yes_04.txt, 01_Yes_05.txt, 01_Yes_06.txt, 01_Yes_07.txt, 01_Yes_08.txt, 01_Yes_09.txt, 01_Yes_10.txt, 01_Yes_11.txt, 01_Yes_12.txt, 01_Yes_13.txt, 01_Yes_14.txt, 01_Yes_15.txt, 01_Yes_16.txt, 01_Yes_17.txt, 01_Yes_18.txt, 01_Yes_19.txt, 01_Yes_20.txt, 02_No_00.txt, 02_No_01.txt, 02_No_02.txt, 02_No_03.txt, 02_No_04.txt, 02_No_05.txt, 02_No_06.txt, 02_No_07.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3456 KiB
00_sample_01.txt AC 1 ms 3476 KiB
00_sample_02.txt AC 1 ms 3520 KiB
01_Yes_00.txt AC 1 ms 3524 KiB
01_Yes_01.txt AC 1 ms 3480 KiB
01_Yes_02.txt AC 1 ms 3476 KiB
01_Yes_03.txt AC 1 ms 3404 KiB
01_Yes_04.txt AC 1 ms 3532 KiB
01_Yes_05.txt AC 1 ms 3404 KiB
01_Yes_06.txt AC 1 ms 3464 KiB
01_Yes_07.txt AC 1 ms 3460 KiB
01_Yes_08.txt AC 1 ms 3524 KiB
01_Yes_09.txt AC 1 ms 3472 KiB
01_Yes_10.txt AC 1 ms 3480 KiB
01_Yes_11.txt AC 1 ms 3520 KiB
01_Yes_12.txt AC 1 ms 3592 KiB
01_Yes_13.txt AC 1 ms 3668 KiB
01_Yes_14.txt AC 1 ms 3524 KiB
01_Yes_15.txt AC 1 ms 3620 KiB
01_Yes_16.txt AC 1 ms 3476 KiB
01_Yes_17.txt AC 1 ms 3672 KiB
01_Yes_18.txt AC 1 ms 3624 KiB
01_Yes_19.txt AC 1 ms 3528 KiB
01_Yes_20.txt AC 1 ms 3468 KiB
02_No_00.txt AC 1 ms 3588 KiB
02_No_01.txt AC 1 ms 3472 KiB
02_No_02.txt AC 1 ms 3672 KiB
02_No_03.txt AC 1 ms 3668 KiB
02_No_04.txt AC 1 ms 3484 KiB
02_No_05.txt AC 1 ms 3620 KiB
02_No_06.txt AC 1 ms 3476 KiB
02_No_07.txt AC 1 ms 3468 KiB