QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#50919#1830. ANDieeWA 13ms3660kbC++17587b2022-09-29 17:20:402022-09-29 17:20:42

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:20:42]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:3660kb
  • [2022-09-29 17:20:40]
  • 提交

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 << 1 << '\n';
		cout << a[1] << '\n';
		return;
	}
	cout << n * 2 - 2 << '\n';
	for (int i = 2; i <= n; ++i) {
		cout << a[i] << ' ' << a[1] << ' ';
	}
	cout << '\n';
}
int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int t;
	cin >> t;
	while (t--)
		solve();
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3660kb

input:

3
1
5
3
0 1 2
2
1 2

output:

1
5
4
1 0 2 0 
-1

result:

ok answer is correct (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 13ms
memory: 3592kb

input:

20000
5
16 13 5 15 20
5
11 0 13 2 17
5
13 12 8 10 18
5
1 8 16 19 5
5
9 12 3 10 13
5
7 0 14 3 16
5
10 3 9 11 6
5
1 0 4 18 14
5
1 10 5 9 12
5
10 18 16 20 17
5
7 8 19 6 1
5
18 7 4 5 12
5
17 4 6 11 7
5
1 0 12 2 15
5
0 15 7 5 4
5
16 3 4 10 14
5
16 0 2 18 14
5
0 16 20 5 3
5
8 9 10 4 6
5
19 2 12 20 13
5
16...

output:

8
2 0 11 0 13 0 17 0 
8
3 0 7 0 14 0 16 0 
8
1 0 4 0 14 0 18 0 
8
1 0 2 0 12 0 15 0 
8
4 0 5 0 7 0 15 0 
8
2 0 14 0 16 0 18 0 
8
3 0 5 0 16 0 20 0 
8
10 0 12 0 17 0 19 0 
8
10 0 13 0 15 0 17 0 
8
2 0 4 0 5 0 16 0 
8
6 0 7 0 17 0 20 0 
8
3 0 9 0 12 0 18 0 
8
10 0 13 0 16 0 18 0 
8
3 2 6 2 11 2 19 2 
...

result:

wrong answer set of ands are not equal (test case 1)