이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define NOT_STONKS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
const int maxn = 2e5 + 10; //4e6 + 10; //3e5 + 10;
const int mod = 1e9 + 7; //998244353;
typedef long long ll;
int n, m, k;
map<int, bool> br, bc, mpr, mpc;
ll ans = 0;
ll power(ll x, int y) {
if (y == 0) return 1;
if (y == 1) return x;
ll tmp = power(x, y >> 1);
if (y & 1)
return tmp * tmp % mod * x % mod;
return tmp * tmp % mod;
}
int main() {
NOT_STONKS;
cin >> n >> m >> k;
bool R = true, C = true, lanat_be = true, in_zendegi = true;
for (int i = 0; i < k; i++) {
int x, y;
char c;
cin >> c >> x >> y;
int tx = x, ty = y;
if (c == '-') ty ^= 1, tx ^= 1, lanat_be &= (x + y) & 1, in_zendegi &= (x + y) & 1 ^ 1;
else lanat_be &= (x + y) & 1 ^ 1, in_zendegi &= (x + y) & 1;
if (!br[x]) br[x] = true, mpr[x] = ty & 1;
else R &= (mpr[x] & 1) == (ty & 1);
if (!bc[y]) bc[y] = true, mpc[y] = tx & 1;
else C &= (mpc[y] & 1) == (tx & 1);
}
if (R) ans += power(2, n - int(mpr.size())), ans %= mod;
if (C) ans += power(2, m - int(mpc.size())), ans %= mod;
ans -= (lanat_be + in_zendegi);
cout << ans << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
plusminus.cpp: In function 'int main()':
plusminus.cpp:32:88: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
32 | if (c == '-') ty ^= 1, tx ^= 1, lanat_be &= (x + y) & 1, in_zendegi &= (x + y) & 1 ^ 1;
| ~~~~~~~~^~~
plusminus.cpp:33:34: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
33 | else lanat_be &= (x + y) & 1 ^ 1, in_zendegi &= (x + y) & 1;
| ~~~~~~~~^~~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |