| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1284101 | lmquan | Plus Minus (BOI17_plusminus) | C++20 | 88 ms | 9812 KiB | 
#define taskname ""
#include <bits/stdc++.h>
using namespace std;
const long long kMod = 1e9 + 7;
long long Power(long long a, long long b) {
  a %= kMod;
  long long c = 1;
  for (; b > 0; b >>= 1, a = a * a % kMod) {
    if (b & 1) {
      c = c * a % kMod;
    }
  }
  return c;
}
int main() {
  if (fopen(taskname".inp", "r")) {
    freopen(taskname".inp", "r", stdin);
    freopen(taskname".out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, k;
  cin >> n >> m >> k;
  map<int, int> u, v;
  vector<char> b(2, '?');
  bool a1 = true, a2 = true, a3 = true;
  for (int i = 1; i <= k; i++) {
    char z;
    int y, x;
    cin >> z >> y >> x;
    int p = (((z == '+' ? 1 : 0) - x) % 2 == 0 ? 2 : 1);
    if (u[y] > 0 && u[y] != p) {
      a1 = false;
    }
    u[y] = p;
    int q = (((z == '+' ? 1 : 0) - y) % 2 == 0 ? 2 : 1);
    if (v[x] > 0 && v[x] != q) {
      a2 = false;
    }
    v[x] = q;
    int r = (y + x) % 2;
    if (b[r] != '?' && b[r] != z) {
      a3 = false;
    }
    b[r] = z;
  }
  long long s = ((a1 ? Power(2, n - u.size()) : 0) + (a2 ? Power(2, m - v.size()) : 0) - a3 - (k == 0)) % kMod;
  if (s < 0) {
    s += kMod;
  }
  cout << s;
  return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
