Submission #879190

#TimeUsernameProblemLanguageResultExecution timeMemory
879190DAleksaPlus Minus (BOI17_plusminus)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int add(int x, int y) { x += y; return (x >= mod ? x - mod : x); } int mul(int x, int y) { return (x * 1LL * y) % mod; } void sadd(int& x, int y) { x = add(x, y); } void smul(int& x, int y) { x = mul(x, y); } int pw(int a, int n) { if(n == 0) return 1; int x = pw(a, n / 2); smul(x, x); if(n % 2 == 1) smul(x, a); return x; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> a[n + 1], b[m + 1]; vector<char> col(n + 1, '.'), row(m + 1, '.'); bool can_col = true, can_row = true; for(int i = 0; i < k; i++) { char c; int x, y; cin >> c >> x >> y; a[x].push_back(y); b[y].push_back(x); char temp = col[x]; if(y % 2 == 1) col[x] = c; else col[x] = (c ^ '+' ^ '-'); if(temp != '.' && temp != col[x]) can_col = false; temp = row[y]; if(x % 2 == 1) row[y] = c; else row[y] = (c ^ '+' ^ '-'); if(temp != '.' && temp != row[y]) can_row = false; } int ans = 0; if(can_col) { int cnt = 0; for(int i = 1; i <= n; i++) cnt += (col[i] == '.'); sadd(ans, pw(2, cnt)); } if(can_row) { int cnt = 0; for(int i = 1; i <= m; i++) cnt += (row[i] == '.'); sadd(ans, pw(2, cnt)); } ans -= (can_col && can_row); cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...