結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー GrenacheGrenache
提出日時 2016-07-10 23:21:57
言語 Java19
(openjdk 21)
結果
AC  
実行時間 320 ms / 5,000 ms
コード長 1,965 bytes
コンパイル時間 4,677 ms
コンパイル使用メモリ 75,560 KB
実行使用メモリ 66,928 KB
最終ジャッジ日時 2023-09-17 17:32:54
合計ジャッジ時間 13,354 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,592 KB
testcase_01 AC 46 ms
49,408 KB
testcase_02 AC 47 ms
49,612 KB
testcase_03 AC 48 ms
49,440 KB
testcase_04 AC 46 ms
49,328 KB
testcase_05 AC 47 ms
49,484 KB
testcase_06 AC 47 ms
49,328 KB
testcase_07 AC 47 ms
49,392 KB
testcase_08 AC 270 ms
62,180 KB
testcase_09 AC 159 ms
55,336 KB
testcase_10 AC 263 ms
61,220 KB
testcase_11 AC 249 ms
56,092 KB
testcase_12 AC 288 ms
63,068 KB
testcase_13 AC 293 ms
62,912 KB
testcase_14 AC 243 ms
60,096 KB
testcase_15 AC 315 ms
66,612 KB
testcase_16 AC 283 ms
61,936 KB
testcase_17 AC 291 ms
63,052 KB
testcase_18 AC 47 ms
49,400 KB
testcase_19 AC 45 ms
49,384 KB
testcase_20 AC 205 ms
60,624 KB
testcase_21 AC 310 ms
66,800 KB
testcase_22 AC 316 ms
66,760 KB
testcase_23 AC 50 ms
49,948 KB
testcase_24 AC 48 ms
49,336 KB
testcase_25 AC 48 ms
49,404 KB
testcase_26 AC 47 ms
49,804 KB
testcase_27 AC 48 ms
49,356 KB
testcase_28 AC 256 ms
61,932 KB
testcase_29 AC 288 ms
63,216 KB
testcase_30 AC 271 ms
62,116 KB
testcase_31 AC 269 ms
62,344 KB
testcase_32 AC 290 ms
62,084 KB
testcase_33 AC 311 ms
66,772 KB
testcase_34 AC 316 ms
65,052 KB
testcase_35 AC 317 ms
66,636 KB
testcase_36 AC 320 ms
66,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder184 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Printer pr = new Printer(System.out);

        int n = sc.nextInt();

        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
        	a[i] = sc.nextLong();
        }

        int ret = 0;
        int p = 0;
        for (int i = 0; i <= 60; i++) {
        	long mask = 0x1L << i;

        	boolean flag = false;
        	for (int j = p; j < n; j++) {
        		if (!flag && (a[j] & mask) != 0) {
        			flag = true;
        			long tmp = a[j];
        			a[j] = a[p];
        			a[p] = tmp;
        			ret++;
        		} else if (flag && (a[j] & mask) != 0) {
        			a[j] ^= a[p];
        		}
        	}
        	if (flag) {
        		p++;
        	}
        }

        pr.println(0x1L << ret);

        pr.close();
        sc.close();
    }

	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0