結果

問題 No.911 ラッキーソート
ユーザー kotatsugamekotatsugame
提出日時 2019-10-18 22:00:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 247 ms / 2,000 ms
コード長 965 bytes
コンパイル時間 1,315 ms
コンパイル使用メモリ 73,108 KB
実行使用メモリ 8,468 KB
最終ジャッジ日時 2023-09-07 22:25:41
合計ジャッジ時間 8,860 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 240 ms
8,248 KB
testcase_14 AC 241 ms
8,276 KB
testcase_15 AC 235 ms
8,428 KB
testcase_16 AC 240 ms
8,204 KB
testcase_17 AC 243 ms
8,272 KB
testcase_18 AC 237 ms
8,200 KB
testcase_19 AC 236 ms
8,400 KB
testcase_20 AC 222 ms
8,184 KB
testcase_21 AC 217 ms
8,468 KB
testcase_22 AC 206 ms
8,152 KB
testcase_23 AC 198 ms
7,888 KB
testcase_24 AC 182 ms
7,076 KB
testcase_25 AC 102 ms
5,384 KB
testcase_26 AC 90 ms
5,124 KB
testcase_27 AC 40 ms
4,376 KB
testcase_28 AC 20 ms
4,380 KB
testcase_29 AC 6 ms
4,380 KB
testcase_30 AC 3 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 239 ms
8,364 KB
testcase_39 AC 205 ms
7,996 KB
testcase_40 AC 6 ms
4,380 KB
testcase_41 AC 224 ms
8,392 KB
testcase_42 AC 108 ms
6,052 KB
testcase_43 AC 247 ms
8,436 KB
testcase_44 AC 230 ms
4,980 KB
testcase_45 AC 227 ms
4,928 KB
testcase_46 AC 176 ms
4,948 KB
testcase_47 AC 234 ms
5,040 KB
testcase_48 AC 163 ms
4,832 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:56:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   56 | main()
      | ^~~~

ソースコード

diff #

#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;
}
0