Submission #630861

#TimeUsernameProblemLanguageResultExecution timeMemory
630861minhcoolRailway (BOI17_railway)C++17
0 / 100
31 ms3580 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 1e5 + 5; const int oo = 1e18 + 7, mod = 1e9 + 7; int n, m, k; set<int> se; set<int> se0, se1, se2, se3; int binpw(int base, int pw){ int ans = 1; while(pw){ if(pw & 1) ans = (ans * base) % mod; base = (base * base) % mod; pw >>= 1; } return ans; } void process(){ cin >> n >> m >> k; for(int i = 1; i <= k; i++){ int x, y; char c; cin >> c >> x >> y; se.insert(x); bool ck1 = (y & 1), ck2 = (c == '+'); if(ck1 ^ ck2) se1.insert(x); else se0.insert(x); ck1 = (x & 1), ck2 = (c == '+'); if(ck1 ^ ck2) se2.insert(y); else se3.insert(y); } bool ok = 1; for(auto it : se){ ok &= (se0.find(it) == se0.end() || se1.find(it) == se1.end()); } if(ok){ int temp = binpw(2, n - se.size()); int ways = (binpw(2, m - se2.size() - se3.size()) + mod - 1) % mod; cout << (temp + ways) % mod; } else{ for(auto it : se2){ if(se3.find(it) != se3.end()){ cout << 0; return; } } cout << binpw(2, m - se2.size() - se3.size()); } } signed main(){ ios_base::sync_with_stdio(0); process(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...