Submission #1275780

#TimeUsernameProblemLanguageResultExecution timeMemory
1275780behradPlus Minus (BOI17_plusminus)C++17
0 / 100
0 ms332 KiB
#include <bits/stdc++.h> using namespace std; // * No One Dies a Virgin, Life Fucks Us All typedef long long ll; #define nl '\n' #define ff first #define ss second #define pb push_back #define sik(x) {cout << x << nl; return;} constexpr ll maxn = 2e5+10, mod = 1e9 + 7, inf = 1e17, SQ = 450, LG = 20; typedef pair<int, int> pii; constexpr inline ll pw(ll a, ll b, const ll mod = mod) { ll res = 1; for (; b ; b /= 2, a = a * a % mod) if (b & 1) res = res * a % mod; return res; } int n, m, k; map<int, int> R, C; char c; inline bool both() { int lst = -1; for (auto&& [k, v] : R) { if (lst == -1) lst = k ^ v; else if (lst != (k ^ v)) return 0; } return 1; } int32_t main() { cin.tie(0)->sync_with_stdio(0); cin >> n >> m >> k; bool row = 1, col = 1; for (int x, y ; k -- ; ) { cin >> c >> x >> y; int f = (c == '+'); if (R.count(x)) row &= (R[x] == (y & 1) ^ f); else R[x] = (y & 1) ^ f; if (C.count(y)) col &= (C[y] == (x & 1) ^ f); else C[y] = (x & 1) ^ f; } ll ans = 0; if (row) ans += pw(2, n - R.size()); if (col) ans += pw(2, m - C.size()); if (both() && (row || col)) ans += mod - 1; while (ans >= mod) ans -= mod; cout << ans << nl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...