Submission #69652842


Source Code Expand

// Problem: 'B - Find Permutation 2'
// Contest: 'AtCoder - UNIQUE VISION Programming Contest 2024 Autumn (AtCoder Beginner Contest 425)'
// URL: 'https://atcoder.jp/contests/abc425/tasks/abc425_b'
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by competitive-companion.el (https://github.com/luishgh/competitive-companion.el)

#include <bits/stdc++.h>

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main() {_;

  int n; cin >> n;
  set<int> s;
  vector<int> v(n);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] != -1) s.insert(v[i]), cnt++;
  }

  if (s.size() != cnt) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (int i = 0, j = 1; i < n; i++) {
      if (j == 1 and s.count(j)) {
        while (j < n and s.count(j) != 0) j++;
      }
      if (v[i] == -1) {
        cout << j << ' ';
        j++;
        while (j < n and s.count(j) != 0) j++;
      } else cout << v[i] << ' ';
    }
    cout << endl;
  }


  return 0;
}

Submission Info

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

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:32:16: warning: comparison of integer expressions of different signedness: ‘std::set<int>::size_type’ {aka ‘long unsigned int’} and ‘int’ [-Wsign-compare]
   32 |   if (s.size() != cnt) {
      |       ~~~~~~~~~^~~~~~

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 3440 KiB
00_sample_01.txt AC 1 ms 3356 KiB
00_sample_02.txt AC 1 ms 3420 KiB
01_Yes_00.txt AC 1 ms 3488 KiB
01_Yes_01.txt AC 1 ms 3628 KiB
01_Yes_02.txt AC 1 ms 3432 KiB
01_Yes_03.txt AC 1 ms 3356 KiB
01_Yes_04.txt AC 1 ms 3572 KiB
01_Yes_05.txt AC 1 ms 3428 KiB
01_Yes_06.txt AC 1 ms 3628 KiB
01_Yes_07.txt AC 1 ms 3436 KiB
01_Yes_08.txt AC 1 ms 3436 KiB
01_Yes_09.txt AC 1 ms 3432 KiB
01_Yes_10.txt AC 1 ms 3440 KiB
01_Yes_11.txt AC 1 ms 3556 KiB
01_Yes_12.txt AC 1 ms 3500 KiB
01_Yes_13.txt AC 1 ms 3424 KiB
01_Yes_14.txt AC 1 ms 3628 KiB
01_Yes_15.txt AC 1 ms 3500 KiB
01_Yes_16.txt AC 1 ms 3528 KiB
01_Yes_17.txt AC 1 ms 3440 KiB
01_Yes_18.txt AC 1 ms 3424 KiB
01_Yes_19.txt AC 1 ms 3500 KiB
01_Yes_20.txt AC 1 ms 3444 KiB
02_No_00.txt AC 1 ms 3500 KiB
02_No_01.txt AC 1 ms 3500 KiB
02_No_02.txt AC 1 ms 3632 KiB
02_No_03.txt AC 1 ms 3444 KiB
02_No_04.txt AC 1 ms 3504 KiB
02_No_05.txt AC 1 ms 3572 KiB
02_No_06.txt AC 1 ms 3632 KiB
02_No_07.txt AC 1 ms 3440 KiB