# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
130422 | 2019-07-15T07:46:13 Z | win11905 | Plus Minus (BOI17_plusminus) | C++11 | 2 ms | 380 KB |
#include <bits/stdc++.h> using namespace std; #define iib tuple<int, int, bool> const int M = 1e9+7; int n, m, k; vector<iib> V; int have; int powMod(int x) { int ret = 1; int v = 2; for(; x; x >>= 1) { if(x & 1) ret = (1ll * ret * v) % M; v = (1ll * v * v) % M; } return ret; } int solve(int n) { sort(V.begin(), V.end(), [](const iib &a, const iib &b) { return get<0>(a) < get<0>(b); }); int ans = 1, pv = 0, ptr = 0; for(;ptr != V.size();) { int i = get<0>(V[ptr]); int f = -1; while(ptr < V.size() and get<0>(V[ptr]) == i) { bool st = (get<1>(V[ptr]) & 1) == get<2>(V[ptr]); if(f == -1) f = st; if(f != st) return 0; ptr++; } ans = (ans * powMod(i - pv - 1)) % M; pv = i; } ans = (ans * powMod(n - pv)) % M; have++; return ans; } int main() { scanf("%d %d %d", &n, &m, &k); for(int i = 0, a, b; i < k; ++i) { char c; scanf(" %c %d %d", &c, &a, &b); V.emplace_back(a, b, c == '+' ? true : false); } int ans = 0; ans += solve(n); for(auto &x : V) swap(get<0>(x), get<1>(x)); ans += solve(m); ans %= M; if(have == 2) ans = (ans - 1 + M) % M; if(k == 0) ans = (ans - 1 + M) % M; printf("%d\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 252 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 252 KB | Output is correct |
11 | Incorrect | 2 ms | 376 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 380 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 252 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 252 KB | Output is correct |
11 | Incorrect | 2 ms | 376 KB | Output isn't correct |
12 | Halted | 0 ms | 0 KB | - |