結果
問題 |
No.184 たのしい排他的論理和(HARD)
|
ユーザー |
![]() |
提出日時 | 2015-05-11 20:53:15 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,411 bytes |
コンパイル時間 | 4,056 ms |
コンパイル使用メモリ | 74,924 KB |
実行使用メモリ | 76,244 KB |
最終ジャッジ日時 | 2024-07-04 11:40:45 |
合計ジャッジ時間 | 10,417 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 WA * 3 TLE * 1 -- * 28 |
ソースコード
import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); long[] inputs = new long[N]; for(int i = 0; i < N; i++){ inputs[i] = -sc.nextLong(); } Arrays.sort(inputs); for(int i = 0; i < N; i++){ inputs[i] = -inputs[i]; } /* for(int i = 0; i < N; i++){ String str = Long.toBinaryString(inputs[i]); for(int j = 0; j < 64 - str.length(); j++){ System.out.print("0"); } System.out.println(str); } System.out.println("--------------------------------------------"); */ int rank = N; for(int cur_index = 0; cur_index < N; cur_index++){ final int cur_keta = Long.numberOfTrailingZeros(Long.highestOneBit(inputs[cur_index])); if(inputs[cur_index] == 0){ rank--; } for(int next_index = cur_index + 1; next_index < N; next_index++){ final int next_keta = Long.numberOfTrailingZeros(Long.highestOneBit(inputs[next_index])); if(cur_keta == next_keta){ inputs[next_index] ^= inputs[cur_index]; } } } /* for(int i = 0; i < N; i++){ String str = Long.toBinaryString(inputs[i]); for(int j = 0; j < 64 - str.length(); j++){ System.out.print("0"); } System.out.println(str); } */ System.out.println(1l << rank); } }