Skip to content

Commit

Permalink
CF2044D Harder Problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicfred committed Dec 16, 2024
1 parent 5d817b9 commit 3d8f720
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions codeforces/cf2044d_harder_problem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Vicfred
// https://codeforces.com/contest/2044/problem/D
// greedy
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
long t;
cin >> t;
while(t--) {
long n;
cin >> n;
vector<long> a(n+1);
for(int i = 1; i <= n; ++i) {
cin >> a[i];
}
set<long> avail;
for(long i = 1LL; i <= n; ++i) {
avail.insert(i);
}
for(long i = 1; i <= n; ++i) {
if(avail.count(a[i]) > 0) {
cout << a[i] << " ";
avail.erase(a[i]);
} else {
cout << *avail.begin() << " ";
avail.erase(avail.begin());
}
}
cout << endl;
}
return 0;
}

0 comments on commit 3d8f720

Please sign in to comment.