QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#414967#7933. Build Permutationpkien01WA 0ms3560kbC++23719b2024-05-20 06:01:302024-05-20 06:01:30

Judging History

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

  • [2024-05-20 06:01:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3560kb
  • [2024-05-20 06:01:30]
  • 提交

answer

/*input
5
4 2 5 1 3
*/
#include <bits/stdc++.h>

using namespace std;


int main() {
	int n; 
	cin >> n;
	if (n == 1) {
		cout << 0 << endl;
	}
	else {
		vector<int> arr(n);
		for (int i = 0; i < n; i++) cin >> arr[i];
		vector<int> perm(n);
		iota(perm.begin(), perm.end(), 0);
		sort(perm.begin(), perm.end(), [&](int i, int j) {return arr[i] < arr[j];});
		bool sol = true;
		int sum = arr[perm.front()] + arr[perm.back()];
		for (int i = 1; i < n - i - 1; i++) {
			if (arr[perm[i]] != arr[perm[n - i - 1]]) {
				sol = false;
				break;
			}
		}
		if (sol) {
			cout << -1 << endl;
		} else {
			for (int i = n - 1; i >= 0; i--) cout << perm[i] << " ";
			cout << endl;
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3560kb

input:

5
4 2 5 1 3

output:

2 0 4 1 3 

result:

wrong answer Integer 0 violates the range [1, 5]