結果
問題 |
No.1741 Arrays and XOR Procedure
|
ユーザー |
![]() |
提出日時 | 2021-11-12 22:55:23 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 735 bytes |
コンパイル時間 | 2,179 ms |
コンパイル使用メモリ | 75,544 KB |
実行使用メモリ | 64,432 KB |
最終ジャッジ日時 | 2024-11-25 20:53:44 |
合計ジャッジ時間 | 23,038 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 WA * 3 |
ソースコード
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, 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; } }