답안 #879190

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879190 2023-11-26T17:59:45 Z DAleksa Plus Minus (BOI17_plusminus) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

const int mod = 1e9 + 7;

int add(int x, int y) { x += y; return (x >= mod ? x - mod : x); }
int mul(int x, int y) { return (x * 1LL * y) % mod; }

void sadd(int& x, int y) { x = add(x, y); }
void smul(int& x, int y) { x = mul(x, y); }

int pw(int a, int n) {
    if(n == 0) return 1;
    int x = pw(a, n / 2);
    smul(x, x);
    if(n % 2 == 1) smul(x, a);
    return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a[n + 1], b[m + 1];
    vector<char> col(n + 1, '.'), row(m + 1, '.');
    bool can_col = true, can_row = true;
    for(int i = 0; i < k; i++) {
        char c;
        int x, y;
        cin >> c >> x >> y;
        a[x].push_back(y);
        b[y].push_back(x);
        char temp = col[x];
        if(y % 2 == 1) col[x] = c;
        else col[x] = (c ^ '+' ^ '-');
        if(temp != '.' && temp != col[x]) can_col = false;
        temp = row[y];
        if(x % 2 == 1) row[y] = c;
        else row[y] = (c ^ '+' ^ '-');
        if(temp != '.' && temp != row[y]) can_row = false;
    }
    int ans = 0;
    if(can_col) {
        int cnt = 0;
        for(int i = 1; i <= n; i++) cnt += (col[i] == '.');
        sadd(ans, pw(2, cnt));
    }
    if(can_row) {
        int cnt = 0;
        for(int i = 1; i <= m; i++) cnt += (row[i] == '.');
        sadd(ans, pw(2, cnt));
    }
    ans -= (can_col && can_row);
    cout << ans;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -