pdpd123

Problem 12

Feb 17th, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.38 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define pb push_back
  4. #define rep(i,n) for(int i=0;i<int(n);i++)
  5. #define rep1(i,n) for(int i=1;i<=int(n);i++)
  6. #define mp make_pair
  7. #define F first
  8. #define S second
  9. #define IOS ios_base::sync_with_stdio(0); cin.tie(0)
  10. #define INF 0x3f3f3f3f
  11.  
  12. typedef long long ll;
  13. typedef pair<ll,ll> pii;
  14. typedef pair<double,double> pdd;
  15. const ll mod=1e9+7;
  16. ll n,k;
  17. ll h,w;
  18. ll r[1005],c[1005];
  19. ll d[1005][1005];
  20. ll mypow(ll a,ll b){
  21.     ll res=1LL;
  22.     while(b){
  23.         if(b&1) res=res*a%mod;
  24.         a=a*a%mod;
  25.  
  26.         b>>=1;
  27.     }
  28.     return res;
  29. }
  30. int main()
  31. {
  32.     IOS;
  33.     while(cin>>h>>w)
  34.     {
  35.         memset(r,0,sizeof(r));
  36.         memset(c,0,sizeof(c));
  37.         memset(d,0,sizeof(d));
  38.         ll sum=0;
  39.         rep1(i,h) cin>>r[i];
  40.         rep1(i,w) cin>>c[i];
  41.         rep1(i,h) rep1(j,r[i]) d[i][j]=1;
  42.         rep1(j,w) rep1(i,c[j]) d[i][j]=1;
  43.         bool flag=true;
  44.         rep1(i,h) if(d[i][r[i]+1]==1) flag=false;
  45.         rep1(j,w) if(d[c[j]+1][j]==1) flag=false;
  46.  
  47.         //rep1(i,h) {rep1(j,w) cout<<d[i][j]<<" ";cout<<'\n';}
  48.         for(int i=2;i<=h;i++)
  49.         {
  50.             for(int j=2;j<=w;j++)
  51.             {
  52.                 //cout<<i<<' '<<j<<' '<<c[]
  53.                 if(d[i][j]==0&&i>=c[j]+2&&j>=r[i]+2) sum++;
  54.  
  55.             }
  56.         }
  57.         if(!flag) cout<<"0\n";
  58.         else cout<<mypow(2,sum)<<'\n';
  59.  
  60.     }
  61.     return 0;
  62. }
Add Comment
Please, Sign In to add comment