結果
| 問題 |
No.1493 隣接xor
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-12-04 13:30:16 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 109 ms / 2,000 ms |
| コード長 | 772 bytes |
| コンパイル時間 | 3,123 ms |
| コンパイル使用メモリ | 119,296 KB |
| 最終ジャッジ日時 | 2025-01-26 03:32:41 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
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++)
const u64 MOD = 1000000007;
int main(){
int N; cin >> N;
vector<i64> A(N+1, 0);
rep(i,N) cin >> A[i+1];
rep(i,N) A[i+1] ^= A[i];
map<i64, u64> G;
u64 ans = 1;
for(int i=1; i<=N-1; i++){
i64 a = A[i];
u64& g = G[a];
u64 c = (ans + MOD - g) % MOD;
g = ans;
ans = (ans + c) % MOD;
}
cout << ans << 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