Submission #1776395


Source Code Expand

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,m,k,fb[22][22],s[2][1<<20];
const ll MOD=1e9+7; 
int main()
{
	scanf("%d%d%d",&n,&m,&k); --n;
	for(int i=1,a,b,c;i<=k;++i)
		scanf("%d%d%d",&a,&b,&c),fb[a][b-1]|=1<<(!c);
	s[0][0]=1; int x=0;
	for(int i=1;i<=m;++i)
	{
		for(int j=0;j<n;++j)
		{
			x^=1; memset(s[x],0,sizeof s[x]);
			for(int r=0;r<(1<<n);++r)
			{
				bool a=(r>>j)&1;
				for(int w=a;w<=1;++w)
				{
					if(fb[i][j]&(1<<w)) continue;
					if(w==a) (s[x][r]+=s[!x][r])%=MOD;
					else
					{
						int g=r|(1<<j),tt=r>>j;
						if(tt) g^=tt&-tt;
						(s[x][g]+=s[!x][r])%=MOD;
					}
				}
			}
		}
	}
	ll ans=0;
	for(int r=0;r<(1<<n);++r) ans+=s[x][r];
	printf("%lld\n",ans%MOD);
}

Submission Info

Submission Time
Task F - Zigzag
User fjzzq2002
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1731 Byte
Status WA
Exec Time 1418 ms
Memory 8576 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:36:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&m,&k); --n;
                          ^
./Main.cpp:38:47: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&a,&b,&c),fb[a][b-1]|=1<<(!c);
                                               ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1600
Status
AC × 2
WA × 2
AC × 6
WA × 35
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt, sample4.txt
All sample1.txt, sample2.txt, sample3.txt, sample4.txt, a1.txt, a10.txt, a11.txt, a12.txt, a13.txt, a2.txt, a3.txt, a4.txt, a5.txt, a6.txt, a7.txt, a8.txt, a9.txt, b1.txt, b10.txt, b11.txt, b12.txt, b13.txt, b14.txt, b15.txt, b16.txt, b17.txt, b2.txt, b3.txt, b4.txt, b5.txt, b6.txt, b7.txt, b8.txt, b9.txt, n18.txt, n19.txt, n20.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
Case Name Status Exec Time Memory
a1.txt WA 8 ms 8448 KB
a10.txt WA 1333 ms 8448 KB
a11.txt WA 1346 ms 8448 KB
a12.txt WA 1337 ms 8448 KB
a13.txt AC 1250 ms 8448 KB
a2.txt WA 8 ms 8448 KB
a3.txt WA 8 ms 8448 KB
a4.txt WA 23 ms 8448 KB
a5.txt WA 68 ms 8448 KB
a6.txt WA 1418 ms 8448 KB
a7.txt WA 1383 ms 8448 KB
a8.txt WA 1382 ms 8448 KB
a9.txt WA 1354 ms 8448 KB
b1.txt WA 41 ms 8448 KB
b10.txt WA 1364 ms 8448 KB
b11.txt WA 1337 ms 8448 KB
b12.txt WA 1275 ms 8448 KB
b13.txt WA 1206 ms 8448 KB
b14.txt WA 1145 ms 8448 KB
b15.txt WA 1055 ms 8448 KB
b16.txt WA 1049 ms 8448 KB
b17.txt WA 978 ms 8448 KB
b2.txt WA 685 ms 8448 KB
b3.txt WA 19 ms 8448 KB
b4.txt WA 69 ms 8448 KB
b5.txt AC 8 ms 8448 KB
b6.txt WA 137 ms 8448 KB
b7.txt WA 1363 ms 8448 KB
b8.txt WA 1355 ms 8448 KB
b9.txt WA 1359 ms 8448 KB
n18.txt WA 321 ms 8448 KB
n19.txt WA 643 ms 8448 KB
n20.txt WA 1369 ms 8448 KB
sample1.txt AC 5 ms 8448 KB
sample2.txt AC 5 ms 8448 KB
sample3.txt WA 7 ms 8448 KB
sample4.txt WA 1363 ms 8576 KB