Submission #1122651

#TimeUsernameProblemLanguageResultExecution timeMemory
1122651alexddPlus Minus (BOI17_plusminus)C++20
100 / 100
194 ms12724 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int MOD = 1e9+7; int put(int a, int exp) { if(exp==0) return 1; if(exp%2==0) return put(a*a%MOD,exp/2); else return put(a*a%MOD,exp/2)*a%MOD; } int n,m,k; map<int,int> onlin,oncol; signed main() { cin>>n>>m>>k; bool all1=1,all2=1,good_lin=1,good_col=1; int fixlin=0,fixcol=0; for(int i=1;i<=k;i++) { char ch; int x,y,c; cin>>ch>>x>>y; if(ch=='+') c=1; else c=0; c = (c ^ (x%2) ^ (y%2)) + 1; if(onlin[x]==0) onlin[x] = c, fixlin++; else if(onlin[x]!=c) good_lin = 0; if(oncol[y]==0) oncol[y] = c, fixcol++; else if(oncol[y]!=c) good_col = 0; if(c==1) all2 = 0; else all1 = 0; } int rez=0; if(k==0) { rez += put(2,n) - 2; rez += put(2,m) - 2; rez += 2; rez = (rez + MOD)%MOD; } else if(all1 || all2) { assert(good_lin); assert(good_col); rez += put(2, n - fixlin) - 1; rez += put(2, m - fixcol) - 1; rez++; rez = (rez + MOD)%MOD; } else if(good_lin) { assert(!good_col); rez = put(2, n - fixlin); //cout<<"good_lin\n"; } else if(good_col) { assert(!good_lin); rez = put(2, m - fixcol); //cout<<"good_col\n"; } cout<<rez; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...