QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50916#1830. ANDieeWA 1ms3584kbC++17517b2022-09-29 17:16:562022-09-29 17:16:57

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-29 17:16:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3584kb
  • [2022-09-29 17:16:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, a[N];
void solve() {
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	sort(a + 1, a + n + 1);
	for (int i = 2; i <= n; ++i)
		if ((a[i] & a[1]) != a[1]) {
			puts("-1");
			return;
		}
	if (n == 1) {
		cout << a[1] << '\n';
		return;
	}
	for (int i = 2; i <= n; ++i) {
		cout << a[i] << ' ';
		if (i < n)
			cout << a[1] << ' ';
	}
	cout << '\n';
}
int main() {
	int t;
	cin >> t;
	while (t--)
		solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3584kb

input:

3
1
5
3
0 1 2
2
1 2

output:

5
1 0 2 
-1

result:

wrong answer Integer parameter [name=integer] equals to -1, violates the range [0, 1048575] (test case 1)