結果

問題 No.911 ラッキーソート
ユーザー tko919tko919
提出日時 2019-10-19 20:19:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,025 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 164,204 KB
実行使用メモリ 114,700 KB
最終ジャッジ日時 2023-09-09 23:53:30
合計ジャッジ時間 15,171 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,632 KB
testcase_02 AC 2 ms
5,576 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 6 ms
9,584 KB
testcase_41 WA -
testcase_42 AC 169 ms
75,204 KB
testcase_43 WA -
testcase_44 AC 87 ms
114,460 KB
testcase_45 AC 89 ms
114,516 KB
testcase_46 AC 83 ms
114,452 KB
testcase_47 AC 89 ms
114,456 KB
testcase_48 AC 78 ms
110,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
typedef long long int ll;
//template end

int n; ll a[200010],b[200010][70]={},dp[70][2]={};
ll sum(ll x){
    if(x==-1)return 0;
    dp[63][0]=1;
    rrep(i,62,-1)rep(j,0,2)if(dp[i+1][j]){
        rep(k,0,2){
            int nj=j; bool can=1;
            if(!j&&k&&!(x>>i&1))continue;
            if((x>>i&1)&&!k)nj=1;
            rep(l,0,n-1){
                if(b[l][i+1]==b[l+1][i+1]){
                    if(k==0){
                        if((a[l]>>i&1)>(a[l+1]>>i&1))can=0;
                    }
                    else if((a[l]>>i&1)<(a[l+1]>>i&1)) can=0;
                }
            }
            if(can)dp[i][nj]+=dp[i+1][j];
        }
    }return dp[0][0]+dp[0][1];
}

int main(){
    ll l,r; scanf("%d%lld%lld",&n,&l,&r);
    rep(i,0,n){
        scanf("%lld",&a[i]);
        rep(j,0,65)b[i][j]=(a[i]>>j);
    }
    printf("%lld\n",sum(r)-sum(l-1));
    return 0;
}
0