Submission #132492

# Submission time Handle Problem Language Result Execution time Memory
132492 2019-07-19T04:30:12 Z 김세빈(#3198) Plus Minus (BOI17_plusminus) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

const ll mod = 1e9 + 7;

vector <pll> X, Y;
ll n, m, k, z, ans;

ll pow(ll a, ll b)
{
    ll ret = 1;
    
    for(; b; b>>=1){
        if(b & 1) ret = ret * a % mod;
        a = a * a % mod;
    }
    
    return ret;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    char S[3];
    ll i, j, x, y, s, t;
    
    cin >> n >> m >> k;
    
    for(i=0; i<k; i++){
        cin >> S >> x >> y;
        X.emplace_back(x, (*S == '+') ^ (y & 1));
        Y.emplace_back(y, (*S == '+') ^ (x & 1));
        z |= 1 << ((*S == '+') ^ ((x ^ y) & 1));
    }
    
    sort(X.begin(), X.end());
    
    s = pow(2, n);
    
    for(i=0; i<k; i=j){
        for(j=i, t=0; X[i].first == X[j].first; j++){
            t |= 1 << X[j].second;
        }
        if(t == 3) s = 0;
        else s = s * (mod + 1) / 2 % mod;
    }
    
    ans = s;
    
    sort(Y.begin(), Y.end());
    
    s = pow(2, m);
    
    for(i=0; i<k; i=j){
        for(j=i, t=0; Y[i].first == Y[j].first; j++){
            t |= 1 << Y[j].second;
        }
        if(t == 3) s = 0;
        else s = s * (mod + 1) / 2 % mod;
    }
    
    ans = (ans + s) % mod;
    
    if(z == 1 || z == 2){
        ans = (ans + mod - 1) % mod;
    }
    
    cout << ans << "\n";
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -