結果
| 問題 |
No.1493 隣接xor
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-19 14:33:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 2,000 ms |
| コード長 | 535 bytes |
| コンパイル時間 | 859 ms |
| コンパイル使用メモリ | 79,396 KB |
| 実行使用メモリ | 15,232 KB |
| 最終ジャッジ日時 | 2024-09-20 06:21:35 |
| 合計ジャッジ時間 | 5,788 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
const long long md = 1000000007;
int a[200009];
long long d[200009];
map<int, int> mp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
a[i] ^= a[i - 1];
}
d[0] = 1;
for (int i = 1; i < n; i++) {
if (mp.find(a[i]) == mp.end())
d[i] = (d[i - 1] * 2) % md;
else
d[i] = (d[i - 1] * 2 - d[mp[a[i]] - 1] + md) % md;
mp[a[i]] = i;
}
cout << d[n - 1] << '\n';
return 0;
}