Submission #1120416

#TimeUsernameProblemLanguageResultExecution timeMemory
1120416mmdrzadaPlus Minus (BOI17_plusminus)C++17
54 / 100
31 ms16468 KiB
#include <bits/stdc++.h> using namespace std; typedef vector<int> vi; typedef vector<char> vc; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; #define sep ' ' #define F first #define S second #define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define pb push_back #define kill(x) {cout << x << endl;return;} #define sz(x) int(x.size()) #define SP(x) setprecision(x) #define mod(x) (1ll*x%M+M)%M #define pq priority_queue #define mid (l+r)/2 // #define mid2 (l+r+1)/2 #define pll pair<ll, ll> #define REP(i, k) for (int i = 0 ; i < k ; i ++) #define MP make_pair #define int ll const int M = 1e9+7; const int N = 1000+1; int n, m, k; int t[N][N]; int r[N], c[N]; void solve() { cin >> n >> m >> k; memset(t, -1, sizeof t); assert(n <= 1000 && m <= 1000); for(int i = 0 ; i < k ; i ++) { char c; int x, y; cin >> c >> x >> y; x--, y--; t[x][y] = c == '+'; } // -1 : undetermined // 0 : - // +1 : + int R = 1, C = 1; for(int i = 0 ; i < n && R ; i ++) { bool bad01 = false, bad10 = false; for(int j = 0 ; j < m && !bad01 ; j ++) { // 010101... if ((t[i][j] == 0 && j%2 == 1) || (t[i][j] == 1 && j%2 == 0)) bad01 = true; } for(int j = 0 ; j < m && !bad10 ; j ++) { // 101010... if ((t[i][j] == 0 && j%2 == 0) || (t[i][j] == 1 && j%2 == 1)) bad10 = true; } R = 1ll*R*(!bad01+!bad10)%M; } for(int j = 0 ; j < m && C > 0; j ++) { bool bad01 = false, bad10 = false; for(int i = 0 ; i < n && !bad01 ; i ++) { // 01010101 if ((i%2 == 0 && t[i][j] == 1) || (i%2 == 1 && t[i][j] == 0)) bad01 = true; } for(int i = 0 ; i < n && !bad10 ; i ++) { // 101010 if ((i%2 == 0 && t[i][j] == 0) || (i%2 == 1 && t[i][j] == 1)) bad10 = true; } C = 1ll*C*(!bad01+!bad10)%M; } bool bad0 = false, bad1 = false; for(int i = 0 ; i < n && !bad0 ; i ++) { for(int j = 0 ; j < m && !bad0 ; j ++) { if (((i+j)%2 == 0 && t[i][j] == 1) || ((i+j)%2 == 1 && t[i][j] == 0)) { bad0 = true; } } } for(int i = 0 ; i < n && !bad1 ; i ++) { for(int j = 0 ; j < m && !bad1 ; j ++) { if (((i+j)%2 == 1 && t[i][j] == 1) || ((i+j)%2 == 1 && t[i][j] == 1)) { bad1 = true; } } } cout << mod(0ll+R+C-(!bad0)-(!bad1)) << endl; } // check MAXN int32_t main() { fastIO; solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...