QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#50916 | #1830. AND | iee | WA | 1ms | 3584kb | C++17 | 517b | 2022-09-29 17:16:56 | 2022-09-29 17:16:57 |
Judging History
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();
}
详细
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)