Submission #129936

#TimeUsernameProblemLanguageResultExecution timeMemory
129936davitmargPlus Minus (BOI17_plusminus)C++17
100 / 100
162 ms7900 KiB
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <set> #include <queue> #include <iomanip> #include <stack> #include <cassert> #include <iterator> #include <bitset> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(),v.end() using namespace std; LL binpow(LL a,LL n) { if(n==0) return 1; if(n%2==0) return binpow((a*a)%mod,n/2); return (a*binpow(a,n-1))%mod; } int n,m,k,y[100005],x[100005],cnt; char c[100005]; LL ans; void solve() { map<int,int> val; for(int i=1;i<=k;i++) { val[x[i]]|=((c[i]=='+')^((y[i]-1)%2))+1; if(val[x[i]]==3) return; } ans+=binpow(2,m-val.size()); ans%=mod; cnt++; } int main() { cin>>n>>m>>k; for(int i=1;i<=k;i++) scanf(" %c%d%d",c+i,y+i,x+i); solve(); swap(m,n); for(int i=1;i<=k;i++) swap(y[i],x[i]); solve(); if(cnt==2) ans-=1+(k==0); cout<<ans<<endl; return 0; } /* */

Compilation message (stderr)

plusminus.cpp: In function 'int main()':
plusminus.cpp:61:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for(int i=1;i<=k;i++)
     ^~~
plusminus.cpp:63:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  solve();
  ^~~~~
plusminus.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c%d%d",c+i,y+i,x+i);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...