제출 #879189

#제출 시각아이디문제언어결과실행 시간메모리
879189DAleksaPlus Minus (BOI17_plusminus)C++17
0 / 100
2 ms604 KiB
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int add(int x, int y) { x += y; return (x >= mod ? x - mod : x); } int mul(int x, int y) { return (x * 1LL * y) % mod; } int sadd(int& x, int y) { x = add(x, y); } int smul(int& x, int y) { x = mul(x, y); } int pw(int a, int n) { if(n == 0) return 1; int x = pw(a, n / 2); smul(x, x); if(n % 2 == 1) smul(x, a); return x; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> a[n + 1], b[m + 1]; vector<char> col(n + 1, '.'), row(m + 1, '.'); bool can_col = true, can_row = true; for(int i = 0; i < k; i++) { char c; int x, y; cin >> c >> x >> y; a[x].push_back(y); b[y].push_back(x); char temp = col[x]; if(y % 2 == 1) col[x] = c; else col[x] = (c ^ '+' ^ '-'); if(temp != '.' && temp != col[x]) can_col = false; temp = row[y]; if(x % 2 == 1) row[y] = c; else row[y] = (c ^ '+' ^ '-'); if(temp != '.' && temp != row[y]) can_row = false; } int ans = 0; if(can_col) { int cnt = 0; for(int i = 1; i <= n; i++) cnt += (col[i] == '.'); sadd(ans, pw(2, cnt)); } if(can_row) { int cnt = 0; for(int i = 1; i <= m; i++) cnt += (row[i] == '.'); sadd(ans, pw(2, cnt)); } ans -= (can_col && can_row); cout << ans; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

plusminus.cpp: In function 'int sadd(int&, int)':
plusminus.cpp:10:42: warning: no return statement in function returning non-void [-Wreturn-type]
   10 | int sadd(int& x, int y) { x = add(x, y); }
      |                                          ^
plusminus.cpp: In function 'int smul(int&, int)':
plusminus.cpp:11:42: warning: no return statement in function returning non-void [-Wreturn-type]
   11 | int smul(int& x, int y) { x = mul(x, y); }
      |                                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...