結果
問題 | No.1846 Good Binary Matrix |
ユーザー | 👑 potato167 |
提出日時 | 2021-08-21 17:05:45 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 577 ms / 2,000 ms |
コード長 | 1,396 bytes |
コンパイル時間 | 2,053 ms |
コンパイル使用メモリ | 199,784 KB |
実行使用メモリ | 26,644 KB |
最終ジャッジ日時 | 2024-04-20 03:23:46 |
合計ジャッジ時間 | 8,594 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,944 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 1 ms
6,944 KB |
testcase_14 | AC | 1 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,944 KB |
testcase_16 | AC | 533 ms
26,644 KB |
testcase_17 | AC | 577 ms
26,432 KB |
testcase_18 | AC | 512 ms
25,960 KB |
testcase_19 | AC | 554 ms
25,108 KB |
testcase_20 | AC | 547 ms
26,612 KB |
testcase_21 | AC | 72 ms
15,108 KB |
testcase_22 | AC | 76 ms
15,896 KB |
testcase_23 | AC | 2 ms
6,944 KB |
testcase_24 | AC | 2 ms
6,944 KB |
testcase_25 | AC | 380 ms
20,088 KB |
testcase_26 | AC | 269 ms
14,192 KB |
testcase_27 | AC | 16 ms
6,944 KB |
testcase_28 | AC | 57 ms
6,944 KB |
testcase_29 | AC | 168 ms
10,624 KB |
testcase_30 | AC | 453 ms
21,916 KB |
testcase_31 | AC | 380 ms
20,364 KB |
testcase_32 | AC | 481 ms
22,536 KB |
testcase_33 | AC | 516 ms
26,208 KB |
testcase_34 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using std::cout; using std::cin; using std::endl; using ll=long long; ll mod=1e9+7; #define rep(i,a) for (ll i=0;i<a;i++) //return x^y (mod z) ll my_pow(ll x,ll y,ll z){ if(x==0) return 0; if(y==0) return 1; if(y%2==1) return (x*my_pow(x,y-1,z))%z; return my_pow((x*x)%z,y/2,z); } namespace po167{ struct combination{ std::vector<long long> fact; std::vector<long long> rev; std::vector<long long> fact_rev; long long MOD; combination(int max,long long mod):MOD(mod),fact(max+1),rev(max+1),fact_rev(max+1){ for(long long i=0;i<=max;i++){ if(i<2){ fact[i]=1; fact_rev[i]=1; rev[i]=1; continue; } fact[i]=(fact[i-1]*i)%mod; rev[i]=mod-((mod/i)*rev[mod%i])%mod; fact_rev[i]=(fact_rev[i-1]*rev[i])%mod; } } long long Comb(int x,int y){ if (x<y||y<0) return 0; return (((fact_rev[y]*fact_rev[x-y])%MOD)*fact[x])%MOD; } }; } using po167::combination; void solve(int H,int W); //おちこんだりもしたけれど、私はげんきです。 int main() { int H,W; cin>>H>>W; assert(1<=H&&H<=(int)(1e6)); assert(1<=W&&W<=(int)(1e6)); solve(H,W); } void solve(int H,int W){ combination C(H,mod); ll ans=0; ll tmp=1; ll sign=1; if((H+W)%2) sign=-1; rep(i,H+1){ ans+=sign*(C.Comb(H,i)*my_pow(1-tmp,W,mod))%mod; ans%=mod; tmp*=2; tmp%=mod; sign*=-1; } cout<<(ans+mod)%mod<<"\n"; }