# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
132494 | 2019-07-19T04:35:33 Z | 조승현(#3204) | Plus Minus (BOI17_plusminus) | C++14 | 2 ms | 376 KB |
#include<cstdio> #include<algorithm> using namespace std; int n, m, K; struct point { int x, y, ck; bool operator <(const point &p)const { return x != p.x ? x < p.x : y < p.y; } }w[101000]; long long Mod = 1000000007; long long Pow(long long a, long long b) { long long r = 1; while (b) { if (b & 1)r = r * a%Mod; a = a * a%Mod; b >>= 1; } return r; } long long Calc(int c1, int c2) { int i; if(c1 && c2){ for (i = 0; i < K; i++) { if ( (((w[i].x^c1) ^ (w[i].y^c2)) & 1) ^ w[i].ck)return 0; } return 1; } if (c1) { sort(w, w + K); int r = n; for (i = 1; i < K; i++) { if (w[i].x == w[i - 1].x && ((w[i].y^w[i - 1].y^w[i].ck^w[i - 1].ck) & 1))return 0; } for (i = 0; i < K; i++)if (i == K - 1 || w[i].x != w[i + 1].x)r--; return Pow(2, r); } else { for (i = 0; i < K; i++)swap(w[i].x, w[i].y); sort(w, w + K); int r = m; for (i = 1; i < K; i++) { if (w[i].x == w[i - 1].x && ((w[i].y^w[i - 1].y^w[i].ck^w[i - 1].ck) & 1))return 0; } for (i = 0; i < K; i++)if (i == K - 1 || w[i].x != w[i + 1].x)r--; for (i = 0; i < K; i++)swap(w[i].x, w[i].y); return Pow(2, r); } } int main() { int i, j; char pp[3]; scanf("%d%d%d", &n, &m, &K); for (i = 0; i < K; i++) { scanf("%s", pp); scanf("%d%d", &w[i].x, &w[i].y); if (pp[0] == '+')w[i].ck = 1; } long long s1 = Calc(1, 0) + Calc(2, 0) + Calc(0, 1) + Calc(0, 2); long long s2 = Calc(1, 1) + Calc(1, 2) + Calc(2, 1) + Calc(2, 2); printf("%lld\n", (s1 - s2 + Mod * 4) % Mod * Pow(2,Mod-2)%Mod); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |