이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// 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 & 1))) != c) {
good[2] = false;
}
if (col.count(y) && (col[y] ^ (6 * (x & 1))) != 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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |