#include "bits/stdc++.h"
using namespace std;
const int M = 1e9+7;
int n, m, k, a[1005][1005], ans;
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
a[i][j] = -1;
}
}
for(int i = 1; i <= k; i++){
char c;
int x, y;
cin >> c >> x >> y;
a[x][y] = (c == '+' ? 1 : 0);
}
long long x = 1, y = 1;
for(int i = 1; i <= n; i++){
int a1 = 1, a2 = 1;
for(int j = 1; j <= m; j++){
if(~a[i][j] and a[i][j] != (j%2)) a1 = 0;
if(~a[i][j] and a[i][j] != (j%2)^1) a2 = 0;
}
x *= (a1+a2);
x %= M;
}
for(int j = 1; j <= m; j++){
int a1 = 1, a2 = 1;
for(int i = 1; i <= n; i++){
if(~a[i][j] and a[i][j] != (i%2)) a1 = 0;
if(~a[i][j] and a[i][j] != (i%2)^1) a2 = 0;
}
y *= (a1+a2);
y %= M;
}
int b1 = 1, b2 = 1;
bool t = 1;
for(int i = 1; i <= n; i++){
t = (i % 2);
for(int j = 1; j <= m; j++){
if(~a[i][j] and a[i][j] != t) b1 = 0;
t = (1-t);
}
}
for(int i = 1; i <= n; i++){
t = (i%2)^1;
for(int j = 1; j <= m; j++){
if(~a[i][j] and a[i][j] != t) b2 = 0;
t = (1-t);
}
}
cout << ((x+y)-(b1+b2)) % M;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |