QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#59280 | #1830. AND | linak | WA | 1208ms | 57628kb | Java11 | 1.1kb | 2022-10-28 21:13:06 | 2022-10-28 21:13:08 |
Judging History
answer
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int g = Integer.parseInt(bf.readLine());
while (g-- > 0) {
HashSet<Integer> ka=new HashSet<>();
int a = Integer.parseInt(bf.readLine());
int[] k=new int[a];
String[] s = bf.readLine().split(" ");
for(int i=0; i<a; i++){
k[i]=Integer.parseInt(s[i]);
ka.add(k[i]);
}
Arrays.sort(k);
int r=(1<<20)-1;
boolean f=true;
for(int i=a-1; i>=0; i--){
r&=k[i];
if(!ka.contains(r)){
f=false;
break;
}
}
if(!f) System.out.println(-1);
else{
System.out.println(a);
for(int i=0; i<a; i++) System.out.print(k[i]+" ");
System.out.println();
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 162ms
memory: 36192kb
input:
3 1 5 3 0 1 2 2 1 2
output:
1 5 3 0 1 2 -1
result:
ok answer is correct (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 1208ms
memory: 57628kb
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 -1 -1 -1 -1 5 0 3 7 14 16 -1 -1 -1 -1 -1 -1 -1 5 0 1 2 12 15 5 0 4 5 7 15 -1 5 0 2 14 16 18 5 0 3 5 16 20 -1 -1 -1 -1 -1 -1 -1 -1 5 0 10 12 17 19 -1 -1 -1 -1 -1 -1 -1 5 0 2 4 5 16 -1 -1 -1 -1 -1 -1 5 0 3 9 12 18 5 0 10 13 16 18 -1 -1 -1 -1 -1 5 2 3 6 11 19 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...
result:
wrong answer the participant did not find the answer for test 2 while jury did it (test case 2)