이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("popcnt")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=2e5+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
const ldb eps=1e-6;
const ldb PI=acos(-1.0);
const int dir[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
template<typename T>
using vvector = vector<vector<T>>;
ll pw(ll a,ll b) {
ll ans=1,now=a;
while (b) {
if (b&1) {
ans*=now;
ans%=P;
}
now*=now;
now%=P;
b>>=1;
}
return ans;
}
int main() {
speed;
int n,m,k;
cin>>n>>m>>k;
map<int,bool> r,c;
int pr=1,pc=1;
for (int i=0;i<k;i++) {
char ch;
int x,y;
cin>>ch>>x>>y;
bool pos=(ch=='+');
if (r.find(x)!=r.end()) {
if (r[x]!=(y&1^pos)) pr=0;
} else r[x]=y&1^pos;
if (c.find(y)!=c.end()) {
if (c[y]!=(x&1^pos)) pc=0;
} else c[y]=x&1^pos;
}
// cout<<pw(2,n-r.size())<<" "<<pw(2,m-c.size())<<" "<<pr*pc%P<<"\n";
if (k) cout<<(pw(2,n-r.size())*pr+pw(2,m-c.size())*pc-pr*pc)%P<<"\n";
else cout<<(pw(2,n)+pw(2,m)-2)%P<<"\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
plusminus.cpp: In function 'int main()':
plusminus.cpp:52:25: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
52 | if (r[x]!=(y&1^pos)) pr=0;
| ~^~
plusminus.cpp:53:22: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
53 | } else r[x]=y&1^pos;
| ~^~
plusminus.cpp:55:25: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
55 | if (c[y]!=(x&1^pos)) pc=0;
| ~^~
plusminus.cpp:56:22: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
56 | } else c[y]=x&1^pos;
| ~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |