// In The Name Of God
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef pair<ll,ll> pll;
#define pb push_back
#define endl '\n'
#define test(x) cout<<x,exit(0)
#define fast (ios_base::sync_with_stdio(false),cin.tie(NULL))
map<int,int>mpr,mpc;
set<int>str,stc;
const int mod=1e9+7;
ll pw(ll a, ll b){
ll res=1;
while(b){
if(b%2){
res*=a;res%=mod;
}
b/=2;
a*=a;a%=mod;
}
return res;
}
int main(){
fast;
int n,m,k;cin>>n>>m>>k;
int okr=1;
int okc=1;
int p1=1;
int p2=1;
for(int i=1;i<=k;i++){
string s;cin>>s;
int x,y;cin>>x>>y;
int val;
if(s[0]=='+'){
val=1;
}
else{
val=0;
}
if((x+y+val)%2==0){
p1=0;
}
else{
p2=0;
}
str.insert(x);
stc.insert(y);
if(mpr[x]!=0 and mpr[x]%2!=(y+val)%2){
okr=0;
}
else{
if((y+val)%2==0){
mpr[x]=2;
}
else{
mpr[x]=1;
}
}
if(mpc[y]!=0 and mpc[y]%2!=(x+val)%2){
okc=0;
}
else{
if((x+val)%2==0){
mpc[y]=2;
}
else{
mpc[y]=1;
}
}
}
ll ans=0;
if(okr==1){
ans+=pw(2,n-str.size());
ans%=mod;
}
if(okc==1){
ans+=pw(2,m-stc.size());
ans%=mod;
}
ans-=p1+p2;
if(ans<0){
ans+=mod;
}
cout<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |