結果

問題 No.916 Encounter On A Tree
ユーザー ogingingoginging
提出日時 2019-10-25 22:05:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,528 bytes
コンパイル時間 1,498 ms
コンパイル使用メモリ 170,848 KB
実行使用メモリ 38,372 KB
最終ジャッジ日時 2023-10-11 04:35:36
合計ジャッジ時間 7,496 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
38,128 KB
testcase_01 AC 56 ms
38,320 KB
testcase_02 AC 56 ms
38,304 KB
testcase_03 AC 55 ms
38,008 KB
testcase_04 AC 53 ms
38,132 KB
testcase_05 AC 54 ms
38,156 KB
testcase_06 AC 56 ms
38,188 KB
testcase_07 AC 55 ms
38,044 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 57 ms
38,208 KB
testcase_11 WA -
testcase_12 AC 58 ms
38,224 KB
testcase_13 WA -
testcase_14 AC 59 ms
38,324 KB
testcase_15 WA -
testcase_16 AC 60 ms
38,296 KB
testcase_17 AC 59 ms
38,024 KB
testcase_18 AC 55 ms
38,168 KB
testcase_19 AC 56 ms
38,256 KB
testcase_20 AC 59 ms
38,128 KB
testcase_21 AC 59 ms
38,168 KB
testcase_22 AC 59 ms
38,088 KB
testcase_23 AC 58 ms
38,024 KB
testcase_24 AC 58 ms
38,200 KB
testcase_25 AC 57 ms
37,944 KB
testcase_26 AC 61 ms
38,044 KB
testcase_27 AC 62 ms
38,216 KB
testcase_28 AC 58 ms
38,108 KB
testcase_29 AC 57 ms
38,272 KB
testcase_30 AC 57 ms
38,128 KB
testcase_31 AC 57 ms
38,156 KB
testcase_32 AC 61 ms
38,088 KB
testcase_33 AC 62 ms
38,268 KB
testcase_34 AC 59 ms
38,148 KB
testcase_35 AC 56 ms
38,124 KB
testcase_36 WA -
testcase_37 AC 56 ms
38,228 KB
testcase_38 AC 59 ms
38,028 KB
testcase_39 AC 58 ms
38,084 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 55 ms
38,156 KB
testcase_43 AC 53 ms
38,132 KB
testcase_44 AC 62 ms
38,172 KB
testcase_45 AC 58 ms
38,268 KB
testcase_46 AC 60 ms
38,060 KB
testcase_47 WA -
testcase_48 AC 55 ms
38,204 KB
testcase_49 WA -
testcase_50 AC 62 ms
38,224 KB
testcase_51 WA -
testcase_52 AC 60 ms
38,220 KB
testcase_53 WA -
testcase_54 AC 57 ms
38,152 KB
testcase_55 AC 57 ms
38,128 KB
testcase_56 AC 59 ms
38,048 KB
testcase_57 AC 60 ms
38,152 KB
testcase_58 WA -
testcase_59 AC 67 ms
38,176 KB
testcase_60 AC 68 ms
38,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<60;
const ll Mod=1e9+7;


vector<ll> inv,fact,invfact;
void Mod_build(int n=1500140){
	fact.resize(n+1);
	inv.resize(n+1);
	invfact.resize(n+1);
	fact[0]=inv[0]=invfact[0]=1;
	inv[1]=1;
	for(ll i=0;i<n;i++){
		fact[i+1]=fact[i]*(i+1)%Mod;
		if(i>0)inv[i+1]=Mod-inv[Mod%(i+1)]*(Mod/(i+1))%Mod;
		invfact[i+1]=invfact[i]*inv[i+1]%Mod;
	}
}
ll perm(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return fact[n]*invfact[n-k]%Mod;
}
ll comb(int n,int k){
	if(n<0||k<0||k>n)return 0;
	return (fact[n]*invfact[n-k]%Mod)*invfact[k]%Mod;
}
ll powMod(ll n,ll k){
	k%=Mod-1;
	if(k<0)k+=Mod-1;
	ll ret=1;
	while(k){
		if(k&1)ret=ret*n%Mod;
		n=n*n%Mod;
		k>>=1;
	}
	return ret;
}

int d,l,r,k;
int depth(int p){
  int cnt=0;
  while(p>=2){
    p=p/2;
    cnt++;
  }
  return cnt;
}

int main(){
  int i,j;
  Mod_build();
  cin>>d>>l>>r>>k;
  l=depth(l);
  r=depth(r);
  if((l+r+k)%2!=0){
    cout<<0<<endl;
    return 0;
  }
  int u=(l+r-k)/2;
  if(u<0||u>min(l,r)){
    cout<<0<<endl;
    return 0;
  }
  ll a=1;
  a*=1<<l;
  for(i=u+1;i<r;i++) {
    a*=2;
    a%=Mod;
  }
  VI used(d,0);
  used[l]++;
  used[r]++;
  for(i=0;i<d;i++){
    if((1<<i)-used[i]<0) continue;
    a*=fact[(1<<i)-used[i]];
    a%=Mod;
  }
  cout<<a<<endl;

  
}
0