結果
問題 | No.1741 Arrays and XOR Procedure |
ユーザー |
![]() |
提出日時 | 2021-11-12 22:57:52 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 642 ms / 2,000 ms |
コード長 | 739 bytes |
コンパイル時間 | 1,999 ms |
コンパイル使用メモリ | 75,020 KB |
実行使用メモリ | 63,324 KB |
最終ジャッジ日時 | 2024-11-25 20:58:19 |
合計ジャッジ時間 | 22,375 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
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;}}