# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
129936 | davitmarg | Plus Minus (BOI17_plusminus) | C++17 | 162 ms | 7900 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |