QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#50925#1830. ANDieeTL 105ms3644kbC++17589b2022-09-29 18:06:402022-09-29 18:06: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 18:06:42]
  • 评测
  • 测评结果:TL
  • 用时:105ms
  • 内存:3644kb
  • [2022-09-29 18:06: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: 3508kb

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: 0
Accepted
time: 47ms
memory: 3568kb

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
8
2 0 11 0 13 0 17 0 
-1
-1
-1
8
3 0 7 0 14 0 16 0 
-1
8
1 0 4 0 14 0 18 0 
-1
-1
-1
-1
-1
8
1 0 2 0 12 0 15 0 
8
4 0 5 0 7 0 15 0 
-1
8
2 0 14 0 16 0 18 0 
8
3 0 5 0 16 0 20 0 
-1
-1
-1
-1
-1
-1
-1
-1
8
10 0 12 0 17 0 19 0 
-1
8
10 0 13 0 15 0 17 0 
-1
-1
-1
-1
-1
8
2 0 4 0 5 0 16 0 
-1
-1
-1
-1...

result:

ok answer is correct (20000 test cases)

Test #3:

score: 0
Accepted
time: 105ms
memory: 3644kb

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
8
11 0 15 0 24 0 29 0 
-1
-1
8
6 0 15 0 21 0 24 0 
-1
-1
-1
8
4 0 13 0 14 0 25 0 
-1
8
4 0 10 0 17 0 24 0 
-1
-1
8
2 0 4 0 7 0 9 0 
8
3 0 26 0 27 0 30 0 
-1
-1
-1
8
6 0 12 0 21 0 25 0 
8
10 0 11 0 14 0 21 0 
-1
-1
8
1 0 10 0 17 0 26 0 
-1
8
11 0 20 0 26 0 29 0 
-1
-1
-1
-1...

result:

ok answer is correct (20000 test cases)

Test #4:

score: 0
Accepted
time: 94ms
memory: 3588kb

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

result:

ok answer is correct (10000 test cases)

Test #5:

score: 0
Accepted
time: 94ms
memory: 3596kb

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:

2
58 40 
-1
2
58 48 
-1
2
47 14 
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
78 4 
2
69 68 
-1
-1
-1
-1
-1
-1
-1
2
58 56 
-1
-1
-1
-1
-1
2
88 16 
-1
-1
-1
-1
-1
-1
-1
2
61 4 
-1
-1
2
63 17 
-1
-1
2
30 8 
-1
-1
-1
-1
2
43 11 
-1
-1
-1
2
83 16 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2
46 38 
-1
-1
-1
...

result:

ok answer is correct (50000 test cases)

Test #6:

score: -100
Time Limit Exceeded

input:

100000
1
506023
1
837326
1
753172
1
328218
1
990879
1
218952
1
394008
1
1011923
1
227745
1
207269
1
840304
1
524657
1
656594
1
848736
1
860274
1
37615
1
593627
1
365335
1
289082
1
400301
1
878184
1
823563
1
9512
1
963056
1
54956
1
143268
1
1019230
1
9311
1
242652
1
986091
1
618563
1
74376
1
751535
1...

output:

1
506023
1
837326
1
753172
1
328218
1
990879
1
218952
1
394008
1
1011923
1
227745
1
207269
1
840304
1
524657
1
656594
1
848736
1
860274
1
37615
1
593627
1
365335
1
289082
1
400301
1
878184
1
823563
1
9512
1
963056
1
54956
1
143268
1
1019230
1
9311
1
242652
1
986091
1
618563
1
74376
1
751535
1
100302...

result: