Submission #00095
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | #include<deque> #include<queue> #include<vector> #include<algorithm> #include<iostream> #include<set> #include<cmath> #include<tuple> #include<string> #include<chrono> #include<functional> #include<iterator> #include<random> #include<unordered_set> #include<array> #include<map> #include<iomanip> #include<assert.h> #include<bitset> #include<stack> #include<memory> using namespace std; using namespace std::chrono; typedef long long int llint; typedef double lldo; #define mp make_pair #define mt make_tuple #define pub push_back #define puf push_front #define pob pop_back #define pof pop_front #define fir first #define sec second #define res resize #define ins insert #define era erase /* cout<<fixed<<setprecision(20); cin.tie(0); ios::sync_with_stdio(false); */ const llint mod=1000000007; const llint big=2.19e15+1; const long double pai=3.141592653589793238462643383279502884197; const long double eps=1e-15; template < class T, class U> bool mineq(T& a,U b){ if (a>b){a=b; return true ;} return false ;} template < class T, class U> bool maxeq(T& a,U b){ if (a<b){a=b; return true ;} return false ;} llint gcd(llint a,llint b){ if (a%b==0){ return b;} else return gcd(b,a%b);} llint lcm(llint a,llint b){ if (a==0){ return b;} return a/gcd(a,b)*b;} template < class T> void SO(T& ve){sort(ve.begin(),ve.end());} template < class T> void REV(T& ve){reverse(ve.begin(),ve.end());} template < class T>llint LBI(vector<T>&ar,T in){ return lower_bound(ar.begin(),ar.end(),in)-ar.begin();} template < class T>llint UBI(vector<T>&ar,T in){ return upper_bound(ar.begin(),ar.end(),in)-ar.begin();} int main( void ){ cin.tie(0); ios::sync_with_stdio( false ); llint H,W,n,i,ans=1;cin>>W>>H>>n; vector<llint>kai(H+W+1);kai[0]=1; for (i=1;i<=H+W;i++){kai[i]=kai[i-1]*i%mod;} vector<llint>gya(H+W+1);gya[H+W]=1; llint bgen=kai[H+W]; for ( int h=0;h<30;h++){ if ((mod-2)&(1<<h)){gya[H+W]*=bgen;gya[H+W]%=mod;} bgen*=bgen;bgen%=mod; } for (i=H+W;i>0;i--){gya[i-1]=gya[i]*i%mod;} int gx=0,gy=0; while (n--){ int x,y;cin>>x>>y; ans*=gya[x-gx];ans%=mod; ans*=gya[y-gy];ans%=mod; ans*=kai[x+y-gx-gy];ans%=mod; gx=x;gy=y; } int x=W-1,y=H-1; ans*=gya[x-gx];ans%=mod; ans*=gya[y-gy];ans%=mod; ans*=kai[x+y-gx-gy];ans%=mod; cout<<ans<<endl; return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0006 - 寄り道 |
ユーザー名 | WA_TLE |
投稿日時 | 2018-11-24 14:29:34 |
言語 | C++17 |
状態 | Accepted |
得点 | 400 |
ソースコード長 | 2309 Byte |
最大実行時間 | 49 ms |
最大メモリ使用量 | 31888 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 400 / 400 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
input01.in | AC | 28 ms | 604 KB |
1
|
input02.in | AC | 18 ms | 404 KB |
1
|
input03.in | AC | 26 ms | 448 KB |
1
|
input04.in | AC | 26 ms | 504 KB |
1
|
input05.in | AC | 20 ms | 592 KB |
1
|
input06.in | AC | 21 ms | 1072 KB |
1
|
input07.in | AC | 23 ms | 1856 KB |
1
|
input08.in | AC | 18 ms | 1660 KB |
1
|
input09.in | AC | 24 ms | 3640 KB |
1
|
input10.in | AC | 25 ms | 3660 KB |
1
|
input11.in | AC | 43 ms | 16104 KB |
1
|
input12.in | AC | 44 ms | 16176 KB |
1
|
input13.in | AC | 37 ms | 9076 KB |
1
|
input14.in | AC | 32 ms | 9140 KB |
1
|
input15.in | AC | 42 ms | 31732 KB |
1
|
input16.in | AC | 48 ms | 31796 KB |
1
|
input17.in | AC | 44 ms | 31852 KB |
1
|
input18.in | AC | 49 ms | 31780 KB |
1
|
input19.in | AC | 44 ms | 31832 KB |
1
|
input20.in | AC | 40 ms | 31888 KB |
1
|
sample.in | AC | 25 ms | 584 KB |
1
|