답안 #630861

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
630861 2022-08-17T09:15:49 Z minhcool Railway (BOI17_railway) C++17
0 / 100
31 ms 3580 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int N = 1e5 + 5;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, m, k;
set<int> se;
set<int> se0, se1, se2, se3;

int binpw(int base, int pw){
    int ans = 1;
    while(pw){
        if(pw & 1) ans = (ans * base) % mod;
        base = (base * base) % mod;
        pw >>= 1;
    }
    return ans;
}

void process(){
	cin >> n >> m >> k;
	for(int i = 1; i <= k; i++){
	    int x, y;
	    char c;
	    cin >> c >> x >> y;
	    se.insert(x);
	    bool ck1 = (y & 1), ck2 = (c == '+');
	    if(ck1 ^ ck2) se1.insert(x);
	    else se0.insert(x);
	    ck1 = (x & 1), ck2 = (c == '+');
	    if(ck1 ^ ck2) se2.insert(y);
	    else se3.insert(y);
	}
	bool ok = 1;
	for(auto it : se){
	    ok &= (se0.find(it) == se0.end() || se1.find(it) == se1.end());
	}
	if(ok){
	    int temp = binpw(2, n - se.size());
	    int ways = (binpw(2, m - se2.size() - se3.size()) + mod - 1) % mod;
	    cout << (temp + ways) % mod;
	}
	else{
	    for(auto it : se2){
	        if(se3.find(it) != se3.end()){
	            cout << 0;
	            return;
	        }
	    }
	    cout << binpw(2, m - se2.size() - se3.size());
	}
}

signed main(){
	ios_base::sync_with_stdio(0);
	process();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 3580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 31 ms 3580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -