Submission #1107086

#TimeUsernameProblemLanguageResultExecution timeMemory
1107086koukirocksPlus Minus (BOI17_plusminus)C++17
0 / 100
1 ms336 KiB
#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)) pc=0; } else r[x]=y&1^pos; if (c.find(y)!=c.end()) { if (c[y]!=(x&1^pos)) pr=0; } else c[y]=x&1^pos; } if (k) cout<<(pw(2,n-r.size())*pr+pw(2,m-c.size())*pc-pr*pc)%P<<"\n"; else cout<<(pw(2,n-r.size())+pw(2,m-c.size())-2)%P<<"\n"; return 0; }

Compilation message (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)) pc=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)) pr=0;
      |                        ~^~
plusminus.cpp:56:22: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   56 |         } else c[y]=x&1^pos;
      |                     ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...