제출 #536303

#제출 시각아이디문제언어결과실행 시간메모리
536303StickfishPlus Minus (BOI17_plusminus)C++17
100 / 100
212 ms14840 KiB
#include <iostream> #include <map> using namespace std; using ll = long long; const ll MOD = 1000000007ll; ll pw(ll a, ll m) { if (!m) return 1; if (m % 2) return pw(a, m - 1) * a % MOD; return pw(a * a % MOD, m >> 1); } signed main() { ll n, m, k; cin >> n >> m >> k; map<ll, ll> mprow; map<ll, ll> mpcellar; bool row = true, cellar = true; ll chess = -1; for (ll aa = 0; aa < k; ++aa) { char c; int i, j; cin >> c >> i >> j; int t = int(c == '+'); if (mprow.find(i) != mprow.end() && mprow[i] != (j + t) % 2) row = false; else mprow[i] = (j + t) % 2; if (mpcellar.find(j) != mpcellar.end() && mpcellar[j] != (i + t) % 2) cellar = false; else mpcellar[j] = (i + t) % 2; //cout << i << ' ' << j << ' ' << t << ' ' << ": " << (i + j + t) % 2 << endl; //cout << chess << ' ' << (i + j + t) % 2 << endl; if (chess == -1 || chess == (i + j + t) % 2) chess = (i + j + t) % 2; else chess = -2; //cout << chess << ' ' << row << ' ' << cellar << endl; } ll ans = 0; if (row) ans += pw(2, n - mprow.size()); if (cellar) ans += pw(2, m - mpcellar.size()); if (row && cellar) { if (chess == -1) { ans += MOD - 2; } else if (chess != -2) { ans += MOD - 1; } } ans %= MOD; cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...