結果
問題 | No.1493 隣接xor |
ユーザー | kotatsugame |
提出日時 | 2021-04-30 21:44:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 200 ms / 2,000 ms |
コード長 | 419 bytes |
コンパイル時間 | 725 ms |
コンパイル使用メモリ | 77,952 KB |
実行使用メモリ | 14,848 KB |
最終ジャッジ日時 | 2024-07-19 01:00:52 |
合計ジャッジ時間 | 4,924 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | main() | ^~~~
ソースコード
#include<iostream>#include<map>#include<atcoder/modint>using namespace std;using mint=atcoder::modint1000000007;int N;int A[2<<17];mint dp[2<<17];main(){cin>>N;int now=0;dp[0]=1;mint sum=1;map<int,int>mp;for(int i=0;i<N;i++){cin>>A[i];now^=A[i];int id=-1;if(mp.find(now)!=mp.end())id=mp[now];mp[now]=i+1;sum+=dp[i+1]=sum;if(id!=-1)sum-=dp[id];}cout<<dp[N].val()<<endl;}