QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#762405 | #8835. Goodman | Esouling | WA | 2ms | 3708kb | C++20 | 793b | 2024-11-19 14:54:02 | 2024-11-19 14:54:10 |
Judging History
answer
#include <bits/stdc++.h>
void solve() {
int n;
std::cin >> n;
std::vector<int> a(n + 1), mp(n + 1), vis(n + 1);
for (int i = 1; i <= n; i ++) {
std::cin >> a[i];
mp[a[i]] = i;
}
std::vector<int> ans;
for (int i = 1; i <= n; i ++) {
if (vis[i]) continue;
if (!vis[mp[i]]) {
vis[i] = 1, vis[mp[i]] = 1;
ans.emplace_back(i);
if (mp[i] != i) ans.emplace_back(mp[i]);
}
}
for (int i = 1; i <= n; i ++) {
if (!vis[i]) {
ans.emplace_back(i);
}
}
for (int i = 0; i < n; i ++) {
std::cout << ans[i] << " \n"[i == n - 1];
}
}
int main() {
int t;
std::cin >> t;
while (t --) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3708kb
input:
2 4 1 2 3 4 6 6 5 4 3 2 1
output:
1 2 3 4 1 6 2 5 3 4
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 2ms
memory: 3480kb
input:
873 6 1 5 2 4 6 3 6 5 1 6 4 3 2 4 1 4 3 2 6 2 1 6 5 4 3 6 4 5 1 3 6 2 6 6 2 1 5 4 3 5 1 5 4 3 2 6 1 2 6 3 5 4 4 2 1 3 4 6 1 6 4 2 3 5 6 6 1 3 5 2 4 6 2 1 4 5 3 6 6 3 4 1 5 2 6 6 4 1 5 2 6 3 6 5 2 1 4 6 3 6 4 1 6 2 3 5 6 5 1 3 4 6 2 6 6 2 5 4 1 3 6 6 2 5 1 4 3 6 5 2 3 6 4 1 6 6 1 2 5 4 3 6 2 3 4 6 1 ...
output:
1 2 3 4 6 5 1 2 3 5 4 6 1 2 4 3 1 2 3 6 4 5 1 3 2 6 4 5 1 3 2 4 5 6 1 2 5 3 4 1 2 3 4 5 6 1 2 3 4 1 2 4 3 5 6 1 2 3 4 6 5 1 2 3 5 6 4 1 3 2 5 6 4 1 2 3 6 4 5 1 3 2 4 6 5 1 2 3 5 4 6 1 2 3 4 6 5 1 5 2 3 6 4 1 4 2 3 6 5 1 6 2 3 4 5 1 2 3 6 4 5 1 5 3 2 6 4 1 5 2 3 4 6 1 4 2 3 5 6 1 5 2 4 6 3 1 3 2 4 5 ...
result:
wrong answer Jury found better answer than participant (test case 1)