제출 #732114

#제출 시각아이디문제언어결과실행 시간메모리
732114TrunktyPlus Minus (BOI17_plusminus)C++14
0 / 100
1 ms212 KiB
#include <bits/extc++.h> using namespace std; typedef long long ll; #define int ll int n,m,k,ans,mod=1e9+7; map<int,vector<int>> row,col; int dopow(int x, int y){ if(y==0){ return 1; } int z = dopow(x,y/2); if(y%2){ return (((z*z)%mod)*x)%mod; } else{ return (z*z)%mod; } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> m >> k; for(int i=1;i<=k;i++){ char a; int b,c; cin >> a >> b >> c; if(a=='-'){ row[b].push_back(c+1); col[c].push_back(b+1); } else{ row[b].push_back(c); col[c].push_back(b); } } bool isrow=true,iscol=true; for(auto it=row.begin();it!=row.end();it++){ int p = (it->second)[0]; for(int i:(it->second)){ if(i%2!=p%2){ isrow = false; } } } for(auto it=col.begin();it!=col.end();it++){ int p = (it->second)[0]; for(int i:(it->second)){ if(i%2!=p%2){ iscol = false; } } } if(isrow and iscol){ ans = dopow(2,n-row.size()); ans += dopow(2,m-col.size()); ans--; ans %= mod; } else if(isrow){ ans = dopow(2,n-row.size()); } else if(iscol){ ans = dopow(2,m-col.size()); } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...