제출 #524625

#제출 시각아이디문제언어결과실행 시간메모리
524625Yazan_AlattarPlus Minus (BOI17_plusminus)C++14
100 / 100
127 ms11748 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define pb push_back #define endl "\n" #define all(x) x.begin(), x.end() const int M = 200007; const ll inf = 1e9; const ll mod = 1e9 + 7; const double pi = acos(-1); const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1}; ll Pow(int n, int p) { if(p == 0) return 1; if(p == 1) return n; ll ret = Pow(n, p / 2); ret = (ret * ret) % mod; if(p % 2) ret = (ret * n) % mod; return ret; } map <int,int> row, col; int n, m, k; bool addrow = 1, addcol = 1; int main() { scanf("%d%d%d", &n, &m, &k); for(int i = 1; i <= k; ++i){ int x, y; char c; cin >> c; scanf("%d%d", &x, &y); if(row[y] && row[y] != (c == '+' ? 1 : -1) * (x % 2 ? 1 : -1)) addrow = 0; row[y] = (c == '+' ? 1 : -1) * (x % 2 ? 1 : -1); if(col[x] && col[x] != (c == '+' ? 1 : -1) * (y % 2 ? 1 : -1)) addcol = 0; col[x] = (c == '+' ? 1 : -1) * (y % 2 ? 1 : -1); } if(addrow && addcol) printf("%lld\n", (Pow(2, m - row.size()) * addrow + Pow(2, n - col.size()) * addcol - 1 - (k == 0)) % mod); else if(addrow) printf("%lld\n", Pow(2, m - row.size())); else if(addcol) printf("%lld\n", Pow(2, n - col.size())); else printf("0\n"); return 0; }

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

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