結果
問題 | No.184 たのしい排他的論理和(HARD) |
ユーザー |
![]() |
提出日時 | 2015-05-11 21:06:02 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 2,031 ms / 5,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 2,058 ms |
コンパイル使用メモリ | 76,520 KB |
実行使用メモリ | 78,156 KB |
最終ジャッジ日時 | 2024-07-04 11:43:17 |
合計ジャッジ時間 | 41,714 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 34 |
ソースコード
import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); PriorityQueue<Long> queue = new PriorityQueue<Long>(Collections.reverseOrder()); for(int i = 0; i < N; i++){ queue.add(sc.nextLong()); } while(!queue.isEmpty()){ final long value = queue.poll(); if(value == 0){ queue.add(value); break; }else{ final long min = Long.highestOneBit(value); while(!queue.isEmpty()){ final long next_value = queue.poll(); if((next_value & min) != 0){ queue.add(next_value ^ value); }else{ queue.add(next_value); break; } } } } final int rank = N - queue.size(); System.out.println(1l << rank); } }