# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
135702 | khsoo01 | Plus Minus (BOI17_plusminus) | C++11 | 237 ms | 15084 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll n, m, k, tot, rc, cc, ans;
map<ll, ll> row, col;
bool rv, cv, tv;
ll two (ll A) {
if(!A) return 1;
ll ret = two(A/2);
ret = ret * ret % mod;
if(A&1) ret = ret * 2 % mod;
return ret;
}
int main()
{
scanf("%lld%lld%lld",&n,&m,&k);
for(int i=1;i<=k;i++) {
ll A, B, C;
char T[2];
scanf("%s%lld%lld",T,&A,&B);
C = (T[0] == '+');
ll X = ((A^B^C)&1)+1;
if(row[A]) {
if(row[A] != X) rv = true;
} else {
row[A] = X;
rc++;
}
if(col[B]) {
if(col[B] != X) cv = true;
} else {
col[B] = X;
cc++;
}
if(tot) {
if(tot != X) tv = true;
} else tot = X;
}
if(!rv) ans = (ans + two(n-rc)) % mod;
if(!cv) ans = (ans + two(m-cc)) % mod;
if(!tv) ans = (ans + mod - 1) % mod;
if(!k) ans = (ans + mod -1) % mod;
printf("%lld\n",ans);
}
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... |