QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#707469#8835. Goodmansenak#WA 3ms3620kbC++20623b2024-11-03 16:08:022024-11-03 16:08:02

Judging History

你现在查看的是最新测评结果

  • [2024-11-03 16:08:02]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3620kb
  • [2024-11-03 16:08:02]
  • 提交

answer

#include <iostream>
#include<set>
#include <cstring>
#include<vector>
#include <algorithm>
#include<map>
#define int long long
using namespace std;
const int N =1e6 + 10;
int a[N];
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	map<int, int> mp;
	vector<int> res;
	for (int i = 1; i <= n; i++) {
		if (!mp[a[i]]) {
			mp[i] = 1;
			mp[a[i]] = 1;
			res.push_back(a[i]);
			if (i == a[i])continue;
			res.push_back(i);
		}
	}
	
	for (auto it : res) {
		cout << it << ' ';
	}
	cout << endl;

}
signed main() {
	int t; cin >> t;
	while (t--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

input:

2
4
1 2 3 4
6
6 5 4 3 2 1

output:

1 2 3 4 
6 1 5 2 4 3 

result:

ok Correct (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3620kb

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 5 2 4 6 5 3 6 
5 1 6 3 4 2 6 
1 4 2 3 
2 1 6 3 5 4 
4 1 5 2 3 4 6 5 
6 1 2 5 4 3 6 
1 5 2 4 3 
1 2 6 3 5 4 6 
2 1 3 4 
1 6 2 4 3 5 6 
6 1 3 5 4 2 5 
2 1 4 3 5 4 6 
3 1 4 2 5 4 6 
4 1 5 3 2 4 6 5 
5 1 2 4 6 5 3 6 
4 1 6 3 2 4 5 6 
5 1 3 4 6 5 2 6 
6 1 2 5 3 4 
6 1 2 5 3 4 5 
5 1 2 3 6 4 
6 1 2 3 5 ...

result:

wrong answer Participant didn't find permutation (test case 1)