結果

問題 No.1741 Arrays and XOR Procedure
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-11-12 22:57:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 610 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 74,188 KB
実行使用メモリ 53,308 KB
最終ジャッジ日時 2024-05-04 10:37:13
合計ジャッジ時間 20,417 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
41,460 KB
testcase_01 AC 122 ms
41,576 KB
testcase_02 AC 117 ms
41,236 KB
testcase_03 AC 521 ms
52,684 KB
testcase_04 AC 118 ms
39,868 KB
testcase_05 AC 502 ms
53,040 KB
testcase_06 AC 507 ms
52,372 KB
testcase_07 AC 610 ms
51,892 KB
testcase_08 AC 579 ms
53,308 KB
testcase_09 AC 538 ms
52,460 KB
testcase_10 AC 578 ms
50,104 KB
testcase_11 AC 564 ms
48,776 KB
testcase_12 AC 478 ms
48,480 KB
testcase_13 AC 521 ms
49,740 KB
testcase_14 AC 588 ms
48,736 KB
testcase_15 AC 547 ms
49,436 KB
testcase_16 AC 201 ms
46,116 KB
testcase_17 AC 410 ms
48,216 KB
testcase_18 AC 511 ms
48,880 KB
testcase_19 AC 197 ms
46,184 KB
testcase_20 AC 601 ms
52,576 KB
testcase_21 AC 544 ms
48,428 KB
testcase_22 AC 520 ms
49,532 KB
testcase_23 AC 382 ms
48,336 KB
testcase_24 AC 218 ms
47,476 KB
testcase_25 AC 586 ms
51,100 KB
testcase_26 AC 401 ms
48,232 KB
testcase_27 AC 192 ms
45,936 KB
testcase_28 AC 481 ms
48,836 KB
testcase_29 AC 546 ms
48,608 KB
testcase_30 AC 535 ms
48,520 KB
testcase_31 AC 205 ms
46,172 KB
testcase_32 AC 368 ms
48,312 KB
testcase_33 AC 485 ms
48,276 KB
testcase_34 AC 280 ms
48,108 KB
testcase_35 AC 167 ms
42,420 KB
testcase_36 AC 230 ms
46,780 KB
testcase_37 AC 413 ms
48,180 KB
testcase_38 AC 610 ms
49,968 KB
testcase_39 AC 420 ms
48,244 KB
testcase_40 AC 166 ms
43,380 KB
testcase_41 AC 286 ms
47,912 KB
testcase_42 AC 201 ms
45,744 KB
testcase_43 AC 114 ms
41,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt();
			int[] B = new int[N];
			for (int i = 0;i < N;++ i) B[i] = sc.nextInt();
			final int MOD = 998_244_353;
			int use = -1, ans = 1, sum = 0;
			for (int i = 0;i < N;++ i) {
				if (B[i] == -1) {
					if (combination_mod2(N - 1, i) == 0) ans = ans * 2 % MOD;
					else ++ use;
				} else if (combination_mod2(N - 1, i) != 0) sum = sum + B[i] & 1;
			}
			if (use < 0 && sum == 0) System.out.println(0);
			else {
				while(use --> 0) ans = ans * 2 % MOD;
				System.out.println(ans);
			}
		}
	}
	
	static int combination_mod2(int n, int k) {
		return (n & k) == k ? 1 : 0;
	}
}
0