#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = -1;
const int mod = 1e9+7;
int n, m, k;
void solve() {
cin >> n >> m >> k;
map<int,pair<int,int>> rwp,rwm,clp,clm;
for(int i = 1; i <= k; i++) {
char tp; cin >> tp;
int x,y; cin >> y >> x;
if(tp == '+') {
if(y%2 == 1) clp[x].fr = 1;
else clp[x].sc = 1;
if(x%2 == 1) rwp[y].fr = 1;
else rwp[y].sc = 1;
}
else {
if(y%2 == 1) clm[x].fr = 1;
else clm[x].sc = 1;
if(x%2 == 1) rwm[y].fr = 1;
else rwm[y].sc = 1;
}
}
int cnf1 = 1;
int cnf2 = 1;
int ans1 = 1;
for(int i = 1; i <= m; i++) {
int ok0 = 1;
if(clm[i].sc || clp[i].fr) ok0 = 0;
int ok1 = 1;
if(clm[i].fr || clp[i].sc) ok1 = 0;
ans1*= (ok0+ok1);
ans1%= mod;
if(i%2 == 1) {
if(!ok1) cnf1 = 0;
if(!ok0) cnf2 = 0;
}
else {
if(!ok1) cnf2 = 0;
if(!ok0) cnf1 = 0;
}
}
int ans2 = 1;
for(int i = 1; i <= n; i++) {
int ok0 = 1;
if(rwm[i].sc || rwp[i].fr) ok0 = 0;
int ok1 = 1;
if(rwm[i].fr || rwp[i].sc) ok1 = 0;
ans2*= (ok0+ok1);
ans2%= mod;
}
cout << ans1+ans2-cnf1-cnf2+mod%mod << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
int tt = 1;
// cin >> tt;
while(tt--) {
solve();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
316 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Incorrect |
2 ms |
468 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |