#include "bits/stdc++.h"
using namespace std;
#define ll long long
const int M = 1e9+7;
int n, m, k, ans;
map <int,int> mpr, mpc;
ll f(int x){
if(x == 0) return 1;
if(x % 2 == 0) return (f(x/2) * f(x/2) * 1LL) % M;
else return (f(x/2) * f(x/2) * 2 * 1LL) % M;
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m >> k;
int n1 = n, m1 = m;
bool tr = 0, tr1 = 0, tr2 = 1, tr3 = 1;
for(int i = 1; i <= k; i++){
char c;
int x, y;
cin >> c >> x >> y;
int a = (c == '+' ? 1 : 0);
if((x+y) % 2 != a) tr2 = 0;
if((x+y) % 2 != a^1) tr3 = 0;
if(!(y % 2)) a = (a+1)%2;
a++;
if(mpr[x] == 0) mpr[x] = a, n--;
else {
if(mpr[x] != a) tr = 1;
}
a = (c == '+' ? 1 : 0);
if(!(x % 2)) a = (a+1)%2;
a++;
if(mpc[y] == 0) mpc[y] = a, m--;
else {
if(mpc[y] != a) tr1 = 1;
}
}
ll ans = 0;
if(!tr) ans += f(n);
ans %= M;
if(!tr1) ans += f(m);
ans %= M;
ans -= (tr2 + tr3);
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |