# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132501 | 2019-07-19T04:56:42 Z | 이온조(#3199) | Plus Minus (BOI17_plusminus) | C++14 | 2 ms | 256 KB |
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; struct mes { int x, y, v; } A[100009]; int N, M, K, ans; void fail() { puts("0"); exit(0); } int solve() { set<int> st; map<int, int> mp; for(int i=0; i<K; i++) { if(mp.find(A[i].x) == mp.end()) mp[A[i].x] = (A[i].y&1) ^ A[i].v; else if(mp[A[i].x] != ((A[i].y&1) ^ A[i].v)) fail(); st.insert(A[i].x + A[i].y + A[i].v & 1); } int c = N - (int)mp.size(), r = 1; while(c--) r *= 2, r %= MOD; ans += r; ans %= MOD; return ((int)st.size() == 1); } int main() { scanf("%d%d%d",&N,&M,&K); if(K == 0) { int c = 1; for(int i=0; i<N; i++) c *= 2, c %= MOD; ans += c; ans %= MOD; c = 1; for(int i=0; i<M; i++) c *= 2, c %= MOD; ans += c; ans %= MOD; printf("%d", ans - 2); return 0; } for(int i=0; i<K; i++) { char c; scanf(" %c%d%d", &c, &A[i].x, &A[i].y); A[i].v = (c == '+' ? 1 : 0); } int c = 0; for(int i=0; i<2; i++) { c += solve(); swap(N, M); for(int j=0; j<K; j++) swap(A[j].x, A[j].y); } printf("%d", (ans - c/2 + MOD) % MOD); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |