Submission #536299

#TimeUsernameProblemLanguageResultExecution timeMemory
536299StickfishPlus Minus (BOI17_plusminus)C++17
12 / 100
1 ms212 KiB
#include <iostream> #include <map> using namespace std; using ll = long long; const ll MOD = 1000000007; ll pw(ll a, ll m) { if (!m) return 1; if (m % 2) return a * pw(a, m - 1) % MOD; return pw(a * a % MOD, m / 2); } 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, i, j; cin >> c >> i >> j; ll t = (c == '+'); if (mprow.find(i) != mprow.end()) { if (mprow[i] != (j + t) % 2) row = false; } else { mprow[i] = (j + t) % 2; } if (mpcellar.find(j) != mpcellar.end()) { if (mpcellar[j] != (i + t) % 2) cellar = false; } else { mpcellar[j] = (i + t) % 2; } if (chess == -1) { chess = (i + j + t) % 2; } else if (chess != (i + j + t) % 2) chess = -2; } ll ans = 0; if (row) ans += pw(2, n - mprow.size()); ans %= MOD; if (cellar) ans += pw(2, m - mpcellar.size()); ans %= MOD; if (row && cellar) { if (chess == -1) { ans += MOD - 2; } else if (chess != -2) { if (n > 5) exit(1); 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...