結果
| 問題 | No.1493 隣接xor |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-24 19:16:50 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 2,000 ms |
| + 650µs | |
| コード長 | 697 bytes |
| 記録 | |
| コンパイル時間 | 2,104 ms |
| コンパイル使用メモリ | 176,804 KB |
| 実行使用メモリ | 15,960 KB |
| 最終ジャッジ日時 | 2026-08-24 19:17:04 |
| 合計ジャッジ時間 | 4,942 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include<iostream>
#include<unordered_map>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;cin>>n;
ll a[n+5];
ll sum[n+5];sum[0]=0;
for(int i=1;i<=n;i++){
cin>>a[i];
sum[i]=sum[i-1]^a[i];
}
unordered_map<ll,ll> mp;
ll total=1; //维护当前前缀子序列
for(int i=1;i<=n-1;i++){
if(mp.find(sum[i])==mp.end()){
mp[sum[i]]=total;
total=(2*total)%MOD;
}else{
ll tmp=total;
total=((2*total-mp[sum[i]])%MOD+MOD)%MOD;
mp[sum[i]]=tmp;
}
}
cout<<total<<endl;
return 0;
}