結果
| 問題 |
No.1741 Arrays and XOR Procedure
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-11-12 21:59:36 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 1,212 bytes |
| コンパイル時間 | 2,063 ms |
| コンパイル使用メモリ | 103,252 KB |
| 最終ジャッジ日時 | 2025-01-25 16:44:25 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)
int main(){
int N; cin >> N;
vector<int> Fdivcnt2(N + 1, 0);
for (int i = 2; i <= N; i++) Fdivcnt2[i] = (i / 2) + Fdivcnt2[i / 2];
int open_sum = 0;
int prob0 = 0;
int prob1 = 0;
rep(i, N) {
int b; cin >> b;
if (Fdivcnt2[i] + Fdivcnt2[N - 1 - i] == Fdivcnt2[N - 1]) {
if (b == 0) open_sum ^= 0;
if (b == 1) open_sum ^= 1;
if (b == -1) prob1 ++;
}
else{
if (b == 0) open_sum ^= 0;
if (b == 1) open_sum ^= 0;
if (b == -1) prob0 ++;
}
}
i64 ans[2] = {};
ans[open_sum] = 1;
rep(i, prob0) {
rep(t, 2) ans[t] = ans[t] * 2 % 998244353;
}
rep(i, prob1) {
ans[0] = ans[1] = (ans[0] + ans[1]) % 998244353;
}
cout << ans[1] << endl;
return 0;
}
struct ios_do_not_sync {
ios_do_not_sync() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
}
} ios_do_not_sync_instance;
Nachia