結果
問題 |
No.1141 田グリッド
|
ユーザー |
![]() |
提出日時 | 2020-08-01 01:26:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,377 bytes |
コンパイル時間 | 742 ms |
コンパイル使用メモリ | 85,088 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-07 00:01:57 |
合計ジャッジ時間 | 6,339 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 10 |
ソースコード
#include<iostream> #include<iomanip> #include<cmath> #include<string> #include<cstring> #include<vector> #include<list> #include<algorithm> #include<map> #include<set> #include<queue> #include<stack> using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define rep(i, n) for(int i=0;i<n;++i) #define rrep(i, n) for(int i=n;i>=0;--i) const int inf=1e9+7; const ll mod=1e9+7; const ll big=1e18; const double PI=2*asin(1); int main() { int H, W; cin>>H>>W; ll A[H][W]; ll sumA = 1; ll tate[H], yoko[W]; for(int i=0;i<H;++i) tate[i] = 1; for(int i=0;i<W;++i) yoko[i] = 1; for(int i=0;i<H;++i) { for(int j=0;j<W;++j) { cin>>A[i][j]; sumA *= A[i][j]; sumA %= mod; tate[i] *= A[i][j]; tate[i] %= mod; yoko[j] *= A[i][j]; yoko[j] %= mod; } } int Q; cin>>Q; int r, c; ll tmp, tmpr, tmpc; ll h, two; for(int i=0;i<Q;++i) { cin>>r>>c; r--; c--; tmp = sumA; tmp *= A[r][c]; tmp %= mod; h = mod - 2; while(h>0) { two = 1; tmpr = tate[r]; tmpc = yoko[c]; while(2*two<h) { two *= 2; tmpr *= tmpr; tmpr %= mod; tmpc *= tmpc; tmpc %= mod; } h -= two; tmp *= tmpr; tmp %= mod; tmp *= tmpc; tmp %= mod; } cout<<tmp<<endl; } }