Submission #821797

#TimeUsernameProblemLanguageResultExecution timeMemory
821797tch1cherinPlus Minus (BOI17_plusminus)C++17
100 / 100
98 ms11728 KiB
// 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...