제출 #388214

#제출 시각아이디문제언어결과실행 시간메모리
388214negar_aPlus Minus (BOI17_plusminus)C++14
100 / 100
524 ms37028 KiB
//!yrt tsuj uoy srettam gnihton no emoc #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define mp make_pair #define pii pair <int, int> #define fast_io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define F first #define S second vector <int> r, c; map <int, vector <int>> row, col; map <int, map <int, int>> mat; ll ans = 0, mod = 1e9 + 7; ll pw(ll a, ll b){ ll res = 1; while(b){ if(b & 1){ res = (res * a) % mod; } a = (a * a) % mod; b /= 2; } return res % mod; } int main(){ fast_io; int n, m, k; cin >> n >> m >> k; for(int i = 0; i < k; i ++){ char ch; int x, y; cin >> ch >> x >> y; row[x].pb(y); col[y].pb(x); mat[x][y] = (ch == '+') - (ch == '-'); r.pb(x); c.pb(y); } sort(r.begin(), r.end()); sort(c.begin(), c.end()); r.resize(distance(r.begin(), unique(r.begin(), r.end()))); c.resize(distance(c.begin(), unique(c.begin(), c.end()))); //fact! : ya satr ha yeki dar mioonan ya sootoon ha! bool f1 = true, f2 = true; int v1 = -1; for(int i : c){ set <int> x; for(int j : col[i]){ x.insert(((i + j) & 1) ^ (mat[j][i] == 1)); } if((int)x.size() >= 2){ f1 = false; } } for(int i : r){ set <int> x; for(int j : row[i]){ x.insert(((i + j) & 1) ^ (mat[i][j] == 1)); } if((int)x.size() >= 2){ f2 = false; } } int x = r.size(), y = c.size(); if(f1){ // cout << "f1!" << endl; ans += pw(2, m - y); ans %= mod; } if(f2){ // cout << "f2!" << endl; ans += pw(2, n - x); ans %= mod; } if(f2 && f1){ // cout << "f3!" << endl; ans --; } if(k == 0){ ans --; } ans = (ans + mod) % mod; cout << ans; return 0; }

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

plusminus.cpp: In function 'int main()':
plusminus.cpp:50:6: warning: unused variable 'v1' [-Wunused-variable]
   50 |  int v1 = -1;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...