結果

問題 No.916 Encounter On A Tree
ユーザー bin101bin101
提出日時 2019-10-25 23:01:25
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,588 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 68,168 KB
実行使用メモリ 19,204 KB
最終ジャッジ日時 2023-10-11 07:52:37
合計ジャッジ時間 4,133 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
18,920 KB
testcase_01 AC 19 ms
18,928 KB
testcase_02 AC 18 ms
19,196 KB
testcase_03 AC 18 ms
18,912 KB
testcase_04 AC 20 ms
18,972 KB
testcase_05 RE -
testcase_06 AC 18 ms
18,924 KB
testcase_07 AC 18 ms
19,068 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 19 ms
18,924 KB
testcase_11 RE -
testcase_12 AC 18 ms
19,028 KB
testcase_13 RE -
testcase_14 AC 18 ms
18,980 KB
testcase_15 RE -
testcase_16 AC 19 ms
18,932 KB
testcase_17 RE -
testcase_18 AC 19 ms
19,204 KB
testcase_19 AC 19 ms
19,076 KB
testcase_20 AC 19 ms
18,984 KB
testcase_21 RE -
testcase_22 AC 18 ms
18,924 KB
testcase_23 RE -
testcase_24 AC 18 ms
18,912 KB
testcase_25 AC 19 ms
18,924 KB
testcase_26 AC 19 ms
18,980 KB
testcase_27 AC 19 ms
18,960 KB
testcase_28 AC 18 ms
19,020 KB
testcase_29 RE -
testcase_30 AC 19 ms
18,928 KB
testcase_31 AC 19 ms
18,912 KB
testcase_32 AC 20 ms
19,016 KB
testcase_33 AC 18 ms
19,044 KB
testcase_34 AC 19 ms
18,984 KB
testcase_35 AC 19 ms
18,980 KB
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 AC 19 ms
19,200 KB
testcase_40 RE -
testcase_41 RE -
testcase_42 AC 19 ms
18,924 KB
testcase_43 AC 20 ms
18,980 KB
testcase_44 AC 18 ms
18,996 KB
testcase_45 AC 18 ms
18,980 KB
testcase_46 AC 19 ms
19,148 KB
testcase_47 RE -
testcase_48 AC 19 ms
18,924 KB
testcase_49 RE -
testcase_50 AC 19 ms
19,072 KB
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 20 ms
18,992 KB
testcase_55 AC 19 ms
18,924 KB
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:30:14: warning: ‘rd’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     int d,ld,rd;
              ^~
main.cpp:47:18: warning: ‘ld’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     for(int i=0;i<ld;i++){
                 ~^~~

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
using namespace std;
#define INF 100000
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
typedef pair< pair<int,int>, int> p; 
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/

int myplus[30];

int main(){
    ll fact[2000000];
    fact[0]=1;
    for(ll i=1;i<2000000;i++){
        fact[i]=i*fact[i-1];
        fact[i]%=MOD;
    }

    int d,ld,rd;
    ll l,r,k,s[30],t[30];
    cin>>d>>l>>r>>k;

    s[1]=1LL; t[1]=1LL;
    for(int i=2;i<=d;i++){
        s[i]=s[i-1]*2;
        t[i]=t[i-1]*2+1;
    }
    for(int i=1;i<=d;i++){
        if(s[i]<=l && l<=t[i]) ld=i;
        if(s[i]<=r && r<=t[i]) rd=i;
    }
    bool flag=false;
    int temp=rd-ld;
    ll ans=1;
    int unko=1;
    for(int i=0;i<ld;i++){
        if(i>1) unko*=2;
        if(temp+i*2==k){
            flag=true;
            if(rd==ld){ //正しく機能
                if(i==1){
                    ans*=2*(t[rd]-s[rd]+1)/2;
                }else{
                    ans*=(t[rd]-s[rd]+1)*unko;
                }
            }else{
                return 1;
                unko/=2;
                if(unko<1) unko=1;
                ans*=unko*(t[rd]-s[rd]+1);
            }
        } 
    }
    if(!flag){
        cout<<0<<endl;
        return 0;
    }
    myplus[ld]--; myplus[rd]--;
    for(int i=1;i<=d;i++){
        ans*=fact[t[i]-s[i]+1+myplus[i]];
        ans%=MOD;
    }
    cout<<ans<<endl;
}

0