Submission #543945

#TimeUsernameProblemLanguageResultExecution timeMemory
543945OttoTheDinoPlus Minus (BOI17_plusminus)C++17
100 / 100
336 ms30600 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i,s,e) for (int i = s; i <= e; ++i) #define rrep(i,s,e) for (int i = s; i >= e; --i) #define pb push_back #define pf push_front #define fi first #define se second #define all(a) a.begin(), a.end() typedef long long ll; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; const ll mod = 1e9+7; long long bin_exp (long long a, long long x) { long long res = 1; while (x>0) { if (x%2) res = res*a%mod; a = a*a%mod; x /= 2; } return res; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, k; cin >> n >> m >> k; if (k==0) { cout << (bin_exp(2,n)+bin_exp(2,m)+mod-2)%mod << "\n"; return 0; } map<int,int> rowh[2], colh[2]; set<int> sepr, sepc; bool fC = 0, fR = 0; while (k--) { char x; int r, c; cin >> x >> r >> c; sepr.insert(r); sepc.insert(c); bool b = (x=='+')^(c%2); rowh[b][r] = 1; if (rowh[!b][r]) fC = 1; b = (x=='+')^(r%2); colh[b][c] = 1; if (colh[!b][c]) fR = 1; } if (fC && fR) cout << "0\n"; else if (fC) cout << bin_exp(2, m-sepc.size()) << "\n"; else if (fR) cout << bin_exp(2, n-sepr.size()) <<"\n"; else { ll res = (bin_exp(2,m-sepc.size()) + bin_exp(2,n-sepr.size()) + mod - 1) % mod; cout << res << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...