Submission #1129359

#TimeUsernameProblemLanguageResultExecution timeMemory
1129359KerimPlus Minus (BOI17_plusminus)C++20
54 / 100
32 ms4168 KiB
#include "bits/stdc++.h" #define ll long long #define move gocum using namespace std; const int MOD = 1e9+7; const int N = 1004; int move[N][N]; int mod(ll x){ return (x%MOD); } int main(){ // freopen("file.in", "r", stdin); memset(move, -1, sizeof move); int n, m, k; scanf("%d%d%d", &n, &m, &k); while (k--){ char c; int x, y; scanf(" %c%d%d", &c, &x, &y); move[x][y] = (c == '+'); } int A = 1, B = 1; for (int i = 1; i <= n; i++){ int zero = 1, one = 1; for (int j = 1; j <= m; j++){ if (~move[i][j] and move[i][j] != j%2) zero = 0; if (~move[i][j] and move[i][j] != !(j%2)) one = 0; } A = mod(A * 1LL * (zero+one)); } for (int j = 1; j <= m; j++){ int zero = 1, one = 1; for (int i = 1; i <= n; i++){ if (~move[i][j] and move[i][j] != i%2) zero = 0; if (~move[i][j] and move[i][j] != !(i%2)) one = 0; } B = mod(B * 1LL * (zero+one)); } int C = 0; int one = 1, two = 1; for (int i = 1; i <= n; i++){ for (int j = 1; j <= m; j++){ int f = (i+j)%2; if (~move[i][j] and move[i][j] != f) one = 0; if (~move[i][j] and move[i][j] != (!f)) two = 0; } } printf("%d\n", mod(A + B - (one+two))); return 0; }

Compilation message (stderr)

plusminus.cpp: In function 'int main()':
plusminus.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d%d%d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
plusminus.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf(" %c%d%d", &c, &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...