結果

問題 No.2061 XOR Sort
ユーザー ks2mks2m
提出日時 2022-08-26 22:11:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,381 bytes
コンパイル時間 2,475 ms
コンパイル使用メモリ 78,800 KB
実行使用メモリ 61,708 KB
最終ジャッジ日時 2024-04-22 00:17:19
合計ジャッジ時間 9,005 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
36,620 KB
testcase_01 AC 48 ms
36,992 KB
testcase_02 AC 45 ms
36,864 KB
testcase_03 AC 50 ms
36,628 KB
testcase_04 AC 49 ms
36,996 KB
testcase_05 AC 47 ms
36,984 KB
testcase_06 AC 46 ms
36,724 KB
testcase_07 AC 48 ms
36,884 KB
testcase_08 AC 47 ms
36,888 KB
testcase_09 AC 46 ms
36,888 KB
testcase_10 AC 46 ms
36,788 KB
testcase_11 AC 46 ms
36,356 KB
testcase_12 AC 46 ms
36,516 KB
testcase_13 WA -
testcase_14 AC 250 ms
51,936 KB
testcase_15 AC 256 ms
52,588 KB
testcase_16 AC 339 ms
61,448 KB
testcase_17 AC 313 ms
55,060 KB
testcase_18 AC 295 ms
54,088 KB
testcase_19 AC 303 ms
54,036 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 255 ms
51,752 KB
testcase_23 WA -
testcase_24 AC 376 ms
61,708 KB
testcase_25 AC 350 ms
60,692 KB
testcase_26 AC 375 ms
61,588 KB
testcase_27 AC 361 ms
61,220 KB
testcase_28 AC 356 ms
61,344 KB
testcase_29 AC 206 ms
46,104 KB
testcase_30 AC 46 ms
36,916 KB
testcase_31 AC 94 ms
39,092 KB
testcase_32 AC 48 ms
36,964 KB
testcase_33 AC 46 ms
36,824 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String[] sa = br.readLine().split(" ");
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int mod = 998244353;
		Hakidasi h = new Hakidasi(a);
		long ans = power(2, h.rank, mod);
		System.out.println(ans);
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			x %= m;
			val = val * x % m;
		}
		return val;
	}

	static class Hakidasi {
		long[] arr;
		int[] msb;
		int n, rank;

		public Hakidasi(long[] a) {
			n = a.length;
			arr = Arrays.copyOf(a, n);
			msb = new int[n];

			for (int i = 62; i >= 0; i--) {
				boolean flg = false;
				for (int j = rank; j < n; j++) {
					if ((arr[j] >> i & 1) == 1) {
						long t = arr[rank];
						arr[rank] = arr[j];
						arr[j] = t;
						flg = true;
						break;
					}
				}
				if (flg) {
					msb[rank] = i;
					for (int j = 0; j < n; j++) {
						if (j != rank && (arr[j] >> i & 1) == 1) {
							arr[j] ^= arr[rank];
						}
					}
					rank++;
				}
			}
		}
	}
}
0