QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#662841 | #8835. Goodman | daoqi# | WA | 0ms | 3624kb | C++20 | 859b | 2024-10-21 11:06:36 | 2024-10-21 11:06:36 |
Judging History
answer
#include<bits/stdc++.h>
using i64 = long long;
using l64 = long double;
void DAOQI() {
int n;
std::cin >> n;
std::vector<int> p(n + 1), q(1);
std::set<int> se;
for (int i = 1; i <= n; i++) {
std::cin >> p[i];
if (p[i] == i) {
se.insert(i);
q.push_back(i);
} else {
if (!se.count(i)) {
q.push_back(i);
se.insert(i);
}
if (!se.count(p[i])) {
q.push_back(p[i]);
se.insert(p[i]);
}
}
}
for (int i = 1; i <= n; i++) {
std::cout << q[i] << " \n"[i == n];
}
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
std::cin >> T;
while (T--) DAOQI();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3616kb
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: 0ms
memory: 3624kb
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 5 3 4 6 1 5 2 3 6 4 1 2 4 3 1 2 3 6 4 5 1 4 2 5 3 6 1 6 2 3 4 5 1 2 5 3 4 1 2 3 6 4 5 1 2 3 4 1 2 6 3 4 5 1 6 2 3 4 5 1 2 3 4 5 6 1 3 2 4 5 6 1 4 2 3 5 6 1 5 2 3 4 6 1 4 2 3 6 5 1 5 2 3 4 6 1 6 2 3 5 4 1 6 2 3 5 4 1 5 2 3 4 6 1 6 2 3 4 5 1 2 3 4 6 5 1 5 2 6 3 4 1 4 2 3 6 5 1 4 2 3 5 6 1 3 2 4 6 ...
result:
wrong answer Jury found better answer than participant (test case 1)