結果
| 問題 |
No.911 ラッキーソート
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-18 22:00:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 246 ms / 2,000 ms |
| コード長 | 965 bytes |
| コンパイル時間 | 776 ms |
| コンパイル使用メモリ | 73,856 KB |
| 実行使用メモリ | 8,568 KB |
| 最終ジャッジ日時 | 2024-06-25 16:01:25 |
| 合計ジャッジ時間 | 8,022 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 46 |
コンパイルメッセージ
main.cpp:56:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
56 | main()
| ^~~~
ソースコード
#include<iostream>
#include<vector>
using namespace std;
int N;
long L,R;
long A[2<<17];
long f(long X)
{
long dp[62][2]={};
dp[0][0]=1;
vector<int>id;
id.push_back(0);
id.push_back(N);
for(int i=0;i<=60;i++)
{
int ok=3;
long test=1LL<<60-i;
vector<int>nxt;
for(int j=0;j+1<id.size();j++)
{
nxt.push_back(id[j]);
int l=id[j],r=id[j+1];
for(;l+1<r;l++)
{
if((A[l]^A[l+1])&test)break;
}
if(l+1==r)continue;
bool flag=true;
for(int k=l+1;k+1<r;k++)if((A[k]^A[k+1])&test)flag=false;
if(!flag)
{
ok=0;
break;
}
else
{
nxt.push_back(l+1);
if(A[l]&test)ok&=2;
else ok&=1;
}
}
nxt.push_back(N);
id=nxt;
for(int k=0;k<2;k++)
{
int lim=k?1:!!(X&test);
for(int l=0;l<=lim;l++)
{
if(~ok&1<<l)continue;
dp[i+1][k||l<lim]+=dp[i][k];
}
}
}
return dp[61][0]+dp[61][1];
}
main()
{
cin>>N>>L>>R;
for(int i=0;i<N;i++)cin>>A[i];
cout<<f(R)-(L==0?0:f(L-1))<<endl;
}