Submission #1129683

#TimeUsernameProblemLanguageResultExecution timeMemory
1129683MuhammetPlus Minus (BOI17_plusminus)C++20
12 / 100
6 ms4164 KiB
#include "bits/stdc++.h" using namespace std; const int M = 1e9+7; int n, m, k, a[1005][1005], ans; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m >> k; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ a[i][j] = -1; } } for(int i = 1; i <= k; i++){ char c; int x, y; cin >> c >> x >> y; a[x][y] = (c == '+' ? 1 : 0); } int x = 1, y = 1; for(int i = 1; i <= n; i++){ int a1 = 1, a2 = 1; for(int j = 1; j <= m; j++){ if(~a[i][j] and a[i][j] != (j%2)) a1 = 0; if(~a[i][j] and a[i][j] != (j%2)^1) a2 = 0; } x *= (a1+a2); x %= M; } for(int j = 1; j <= m; j++){ int a1 = 1, a2 = 1; for(int i = 1; i <= n; i++){ if(~a[i][j] and a[i][j] != (i%2)) a1 = 0; if(~a[i][j] and a[i][j] != (i%2)^1) a2 = 0; } y *= (a1+a2); y %= M; } int b1 = 1, b2 = 1; bool t = 1; for(int i = 1; i <= n; i++){ t = (i % 2); for(int j = 1; j <= m; j++){ t = (1-t); if(~a[i][j] and a[i][j] != t) b1 = 0; } } for(int i = 1; i <= n; i++){ t = (i%2)^1; for(int j = 1; j <= m; j++){ t = (1-t); if(~a[i][j] and a[i][j] != t) b2 = 0; } } cout << (x+y)-(b1+b2) << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...