QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#50917#1830. ANDieeWA 174ms3660kbC++17568b2022-09-29 17:18:242022-09-29 17:18:27

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:18:27]
  • 评测
  • 测评结果:WA
  • 用时:174ms
  • 内存:3660kb
  • [2022-09-29 17:18:24]
  • 提交

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 - 3 << '\n';
	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: 100
Accepted
time: 2ms
memory: 3572kb

input:

3
1
5
3
0 1 2
2
1 2

output:

1
5
3
1 0 2 
-1

result:

ok answer is correct (3 test cases)

Test #2:

score: 0
Accepted
time: 103ms
memory: 3660kb

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:

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

result:

ok answer is correct (20000 test cases)

Test #3:

score: 0
Accepted
time: 66ms
memory: 3580kb

input:

20000
5
9 28 1 21 4
5
21 22 23 9 27
5
24 19 1 29 4
5
8 29 5 3 22
5
6 8 28 7 25
5
30 23 24 29 7
5
8 6 29 26 3
5
20 13 2 8 22
5
10 5 30 8 27
5
15 29 0 11 24
5
14 28 16 18 22
5
12 16 20 21 14
5
15 6 24 21 0
5
22 11 28 30 17
5
10 23 11 18 21
5
18 3 7 27 15
5
25 0 4 13 14
5
27 12 30 11 18
5
4 10 0 17 24
...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
7
11 0 15 0 24 0 29 
-1
-1
7
6 0 15 0 21 0 24 
-1
-1
-1
7
4 0 13 0 14 0 25 
-1
7
4 0 10 0 17 0 24 
-1
-1
7
2 0 4 0 7 0 9 
7
3 0 26 0 27 0 30 
-1
-1
-1
7
6 0 12 0 21 0 25 
7
10 0 11 0 14 0 21 
-1
-1
7
1 0 10 0 17 0 26 
-1
7
11 0 20 0 26 0 29 
-1
-1
-1
-1
-1
7
21 16 23 16 26...

result:

ok answer is correct (20000 test cases)

Test #4:

score: 0
Accepted
time: 40ms
memory: 3656kb

input:

10000
10
18 30 2 8 15 6 3 12 24 17
10
25 19 2 26 29 8 16 18 4 24
10
30 14 27 24 23 18 5 16 4 17
10
30 29 9 8 3 23 13 16 5 11
10
29 4 15 2 3 24 23 0 5 30
10
6 12 8 30 5 10 4 19 22 13
10
21 30 24 25 14 6 1 4 11 23
10
9 14 23 15 25 11 19 5 8 13
10
10 29 8 28 21 14 25 3 11 15
10
14 6 30 23 25 9 17 28 29...

output:

-1
-1
-1
-1
17
2 0 3 0 4 0 5 0 15 0 23 0 24 0 29 0 30 
-1
-1
-1
-1
-1
-1
17
1 0 5 0 6 0 9 0 10 0 17 0 19 0 26 0 30 
17
1 0 3 0 8 0 15 0 18 0 23 0 24 0 27 0 28 
17
1 0 5 0 7 0 11 0 14 0 16 0 17 0 24 0 28 
-1
-1
-1
-1
17
7 0 8 0 15 0 16 0 21 0 23 0 24 0 27 0 29 
-1
17
5 0 6 0 12 0 13 0 16 0 17 0 25 0 ...

result:

ok answer is correct (10000 test cases)

Test #5:

score: -100
Wrong Answer
time: 174ms
memory: 3564kb

input:

50000
2
58 40
2
13 62
2
58 48
2
28 5
2
14 47
2
31 50
2
35 9
2
31 87
2
17 26
2
100 66
2
20 57
2
92 40
2
48 31
2
32 79
2
4 78
2
69 68
2
3 36
2
34 91
2
93 91
2
12 88
2
79 40
2
82 98
2
23 36
2
56 58
2
71 13
2
52 86
2
67 32
2
87 52
2
46 75
2
88 16
2
16 11
2
6 8
2
18 45
2
89 99
2
10 41
2
96 7
2
12 67
2
4 ...

output:

1
58 
-1
1
58 
-1
1
47 
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
78 
1
69 
-1
-1
-1
-1
-1
-1
-1
1
58 
-1
-1
-1
-1
-1
1
88 
-1
-1
-1
-1
-1
-1
-1
1
61 
-1
-1
1
63 
-1
-1
1
30 
-1
-1
-1
-1
1
43 
-1
-1
-1
1
83 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
46 
-1
-1
-1
1
30 
-1
-1
-1
-1
-1
1
42 
-1
-1
-1
...

result:

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