Submission #549483

# Submission time Handle Problem Language Result Execution time Memory
549483 2022-04-15T21:43:26 Z sofapuden Plus Minus (BOI17_plusminus) C++14
0 / 100
1 ms 256 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

ll pw(ll a, ll b){
	ll ret = 1;
	while(b){
		if(b&1)ret = ret * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return ret;
}

int main(){
	int n, m, k; cin >> n >> m >> k;
	vector<pair<char,pair<int,int>>> v(k);
	for(int i = 0; i < k; ++i){
		cin >> v[i].first >> v[i].second.first >> v[i].second.second;
	}
	ll ans = 0;
	{
		map<int,int> M;
		bool ok = 1;
		for(int i = 0; i < k; ++i){
			int x = ((v[i].second.second&1)^(v[i].first == '+'))+1;
			if(M[v[i].second.first]){
				if(M[v[i].second.first] != x)ok = 0;
				break;
			}
			M[v[i].second.first] = x;
		}
		if(ok)ans += pw(2,n-M.size());
	}
	{
		map<int,int> M;
		bool ok = 1;
		for(int i = 0; i < k; ++i){
			int x = ((v[i].second.first&1)^(v[i].first == '+'))+1;
			if(M[v[i].second.second]){
				if(M[v[i].second.second] != x)ok = 0;
				break;
			}
			M[v[i].second.second] = x;
		}
		if(ok)ans += pw(2,m-M.size());
	}
	{
		bool ok = 1;
		for(int i = 0; i < k; ++i){
			if(((v[i].second.first+v[i].second.second)&1) ^ (v[i].first == '-')){
				ok = 0;
				break;
			}
		}
		ans-=ok;
	}
	{
		bool ok = 1;
		for(int i = 0; i < k; ++i){
			if(((v[i].second.first+v[i].second.second)&1) ^ (v[i].first == '+')){
				ok = 0;
				break;
			}
		}
		ans-=ok;
	}
	cout << (ans+MOD) % MOD << '\n';

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -