// govnokoded by tch1cherin
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int get_power(int p) {
if (p < 30) {
return 1 << p;
}
int ans = 1, val = 2;
for (int i = 0; i < __lg(p); i++, val = 1LL * val * val % MOD) {
if ((p >> i) & 1) {
ans = 1LL * ans * val % MOD;
}
}
return ans;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N, M, K;
cin >> N >> M >> K;
map<int, char> row, col;
bool good[4] = {true, true, true, true};
for (int i = 0; i < K; i++) {
char c;
int x, y;
cin >> c >> x >> y;
good[((x + y) & 1) ^ (c == '+') ^ 1] = false;
if (row.count(x) && (row[x] ^ (6 * (y % 2))) != c) {
good[2] = false;
}
if (col.count(y) && (col[y] ^ (6 * (x % 2))) != c) {
good[3] = false;
}
row[x] = c ^ (6 * (y & 1)), col[y] = c ^ (6 * (x & 1));
}
int ans = 0;
if (good[0]) {
ans += MOD - 1;
}
if (good[1]) {
ans += MOD - 1, ans %= MOD;
}
if (good[2]) {
ans += get_power(N - row.size()), ans %= MOD;
}
if (good[3]) {
ans += get_power(M - col.size()), ans %= MOD;
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |