QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#465156 | #8835. Goodman | ucup-team1198# | WA | 1ms | 3592kb | C++20 | 987b | 2024-07-06 17:44:21 | 2024-07-06 17:44:21 |
Judging History
answer
#include <map>
#include <set>
#include <array>
#include <cmath>
#include <deque>
#include <bitset>
#include <random>
#include <string>
#include <vector>
#include <cassert>
#include <complex>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> p(n);
for (int i = 0 ; i < n; ++i) {
cin >> p[i];
--p[i];
}
vector<int> q1;
vector<int> used(n);
for (int i = 0; i < n; ++i) {
for (int j = i; !used[j]; j = p[j]) {
q1.push_back(j);
used[j] = true;
}
}
vector<int> q(n);
for (int i = 0; i < n; ++i) {
q[q1[i]] = i;
}
for (int i = 0; i < n; ++i) {
cout << q[i] + 1 << " ";
}
cout << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tst;
cin >> tst;
while (tst--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
2 4 1 2 3 4 6 6 5 4 3 2 1
output:
1 2 3 4 1 3 5 6 4 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3488kb
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 6 3 4 1 5 3 6 2 4 1 2 4 3 1 2 3 5 6 4 1 4 3 2 5 6 1 4 3 5 6 2 1 2 4 5 3 1 2 3 5 6 4 1 2 3 4 1 2 5 6 4 3 1 5 6 3 4 2 1 2 3 4 5 6 1 3 2 4 5 6 1 3 4 2 5 6 1 5 4 6 2 3 1 3 4 2 6 5 1 4 5 6 2 3 1 5 3 6 4 2 1 6 3 5 4 2 1 5 6 3 2 4 1 4 3 5 6 2 1 2 3 4 6 5 1 3 5 6 2 4 1 3 4 2 6 5...
result:
wrong answer Jury found better answer than participant (test case 8)