結果

問題 No.916 Encounter On A Tree
ユーザー bin101bin101
提出日時 2019-10-25 22:58:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,544 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 68,076 KB
実行使用メモリ 19,280 KB
最終ジャッジ日時 2023-10-11 07:41:38
合計ジャッジ時間 3,770 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
19,068 KB
testcase_01 AC 19 ms
19,148 KB
testcase_02 AC 18 ms
18,996 KB
testcase_03 AC 18 ms
18,988 KB
testcase_04 AC 19 ms
18,980 KB
testcase_05 AC 19 ms
18,928 KB
testcase_06 AC 19 ms
19,072 KB
testcase_07 AC 18 ms
18,932 KB
testcase_08 AC 18 ms
18,920 KB
testcase_09 AC 19 ms
18,932 KB
testcase_10 AC 18 ms
18,992 KB
testcase_11 AC 19 ms
18,956 KB
testcase_12 AC 18 ms
19,144 KB
testcase_13 AC 18 ms
18,920 KB
testcase_14 AC 19 ms
18,932 KB
testcase_15 AC 19 ms
19,048 KB
testcase_16 AC 18 ms
19,048 KB
testcase_17 WA -
testcase_18 AC 18 ms
19,120 KB
testcase_19 AC 18 ms
18,936 KB
testcase_20 AC 18 ms
19,048 KB
testcase_21 WA -
testcase_22 AC 18 ms
18,992 KB
testcase_23 WA -
testcase_24 AC 18 ms
18,936 KB
testcase_25 AC 19 ms
18,924 KB
testcase_26 AC 19 ms
18,932 KB
testcase_27 AC 18 ms
18,940 KB
testcase_28 AC 18 ms
18,992 KB
testcase_29 WA -
testcase_30 AC 19 ms
19,008 KB
testcase_31 AC 19 ms
18,984 KB
testcase_32 AC 19 ms
18,984 KB
testcase_33 AC 18 ms
18,984 KB
testcase_34 AC 19 ms
19,044 KB
testcase_35 AC 19 ms
18,984 KB
testcase_36 AC 19 ms
18,936 KB
testcase_37 AC 19 ms
18,996 KB
testcase_38 WA -
testcase_39 AC 19 ms
19,044 KB
testcase_40 AC 18 ms
19,156 KB
testcase_41 AC 18 ms
18,936 KB
testcase_42 AC 19 ms
19,152 KB
testcase_43 AC 19 ms
18,952 KB
testcase_44 AC 18 ms
19,008 KB
testcase_45 AC 19 ms
18,992 KB
testcase_46 AC 18 ms
19,120 KB
testcase_47 AC 19 ms
18,984 KB
testcase_48 AC 20 ms
18,932 KB
testcase_49 AC 18 ms
18,940 KB
testcase_50 AC 19 ms
18,936 KB
testcase_51 AC 19 ms
18,940 KB
testcase_52 WA -
testcase_53 AC 19 ms
19,068 KB
testcase_54 AC 19 ms
18,932 KB
testcase_55 AC 18 ms
18,992 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 19 ms
19,124 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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{
                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