| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1129359 | Kerim | Plus Minus (BOI17_plusminus) | C++20 | 32 ms | 4168 KiB | 
#include "bits/stdc++.h"
#define ll long long
#define move gocum
using namespace std;
const int MOD = 1e9+7;
const int N = 1004;
int move[N][N];
int mod(ll x){
    return (x%MOD);
}
int main(){
    // freopen("file.in", "r", stdin);
    memset(move, -1, sizeof move);
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    while (k--){
        char c;
        int x, y;
        scanf(" %c%d%d", &c, &x, &y);
        move[x][y] = (c == '+');
    }
    int A = 1, B = 1;
    for (int i = 1; i <= n; i++){
        int zero = 1, one = 1;
        for (int j = 1; j <= m; j++){
            if (~move[i][j] and move[i][j] != j%2)
                zero = 0;
            if (~move[i][j] and move[i][j] != !(j%2))
                one = 0;
        }
        A = mod(A * 1LL * (zero+one));
    }
    for (int j = 1; j <= m; j++){
        int zero = 1, one = 1;
        for (int i = 1; i <= n; i++){
            if (~move[i][j] and move[i][j] != i%2)
                zero = 0;
            if (~move[i][j] and move[i][j] != !(i%2))
                one = 0;
        }
        B = mod(B * 1LL * (zero+one));
    }
    int C = 0;
    int one = 1, two = 1;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            int f = (i+j)%2;
            if (~move[i][j] and move[i][j] != f)
                one = 0;
            if (~move[i][j] and move[i][j] != (!f))
                two = 0;
        }
    }
    printf("%d\n", mod(A + B - (one+two)));
    return 0;
}
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... | ||||
