#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,k,o[10],z[10],rs,i,x,y,b[10];
char c;
void rec(int i)
{
if(i==n)
{
int bl=0,nr;
for(int j=0;j<n-1;j++)
{
for(int t=0;t<m-1;t++)
{
nr=0;
if(b[j]&(1<<t))nr++;
if(b[j]&(1<<(t+1)))nr++;
if(b[j+1]&(1<<t))nr++;
if(b[j+1]&(1<<(t+1)))nr++;
if(nr!=2)
{
bl=1;
break;
}
}
if(bl)break;
}
if(!bl)
{
rs++;
/*for(int j=0;j<n;j++)
{
for(int t=0;t<m;t++)
{
if(b[j]&(1<<t))cout<<1;
else cout<<0;
}
cout<<endl;
}
cout<<endl;*/
}
return;
}
for(int j=0;j<(1<<m);j++)
{
if((o[i]&j)!=o[i] || (z[i]&j)!=0)continue;
b[i]=j;
rec(i+1);
}
}
int main()
{
//freopen("sol.in","r",stdin);
//freopen("sol.out","w",stdout);
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
cin>>n>>m>>k;
for(i=1;i<=k;i++)
{
cin>>c>>x>>y;
x--,y--;
if(c=='+')o[x]|=(1<<y);
else z[x]|=(1<<y);
}
rec(0);
cout<<rs<<endl;
return 0;
}
Compilation message
plusminus.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("O3")
plusminus.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
#pragma GCC optimization("unroll-loops")
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
537 ms |
544 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
380 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
537 ms |
544 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
380 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
537 ms |
544 KB |
Output is correct |
2 |
Correct |
7 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
376 KB |
Output is correct |
4 |
Correct |
3 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
380 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
380 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Runtime error |
3 ms |
632 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
12 |
Halted |
0 ms |
0 KB |
- |