QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#32027#1185. To argue, or not to argueWu_RenWA 134ms6256kbC++141.6kb2022-05-16 08:33:122022-05-16 08:33:14

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-16 08:33:14]
  • Judged
  • Verdict: WA
  • Time: 134ms
  • Memory: 6256kb
  • [2022-05-16 08:33:12]
  • Submitted

answer

#include <bits/stdc++.h>
const int mod=1e9+7;
using namespace std;
int n,m,K,f[2][4096][73],p=0,o=1,C[150][150],fac[150],_k[150];
char a[144][144],b[144][144];
void qmo(int &x){
	x+=(x>>31)&mod;
}
void init(int N){
	for(int i=0;i<=N;i++) for(int j=C[i][0]=1;j<=i;j++) qmo(C[i][j]=C[i-1][j]+C[i-1][j-1]-mod);
	for(int i=fac[0]=1;i<=N;i++) fac[i]=1ll*i*fac[i-1]%mod;
	for(int i=_k[0]=1;i<=N;i++) qmo(_k[i]=_k[i-1]+_k[i-1]-mod);
}
void sol(){
	scanf("%d%d%d",&n,&m,&K);
	for(int i=0;i<n;i++) scanf("%s",a[i]);
	if(n<m){
		for(int i=0;i<n;i++) for(int j=0;j<m;j++) b[j][i]=a[i][j];
		swap(a,b),swap(n,m);
	}
	int cnt=0;
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cnt+=a[i][j]=='.';
	for(int S=0;S<(1<<m);S++) for(int j=0;j<=K;j++) f[0][S][j]=0;
	f[0][0][0]=1,p=0,o=1;
	for(int i=0;i<n;i++) for(int j=0;j<m;j++){
		for(int S=0;S<(1<<m);S++) for(int j=0;j<=K;j++) f[o][S][j]=0;
		for(int S=0;S<(1<<m);S++) if(a[i][j]=='.'||!((S>>j)&1)){
			if((S>>j)&1) for(int k=0;k<K;k++) qmo(f[o][S^(1<<j)][k+1]+=f[p][S][k]-mod);
			else{
				for(int k=0;k<=K;k++) qmo(f[o][S][k]+=f[p][S][k]-mod);
				if(a[i][j]=='.') for(int k=0;k<=K;k++) qmo(f[o][S^(1<<j)][k]+=f[p][S][k]-mod);
				if(a[i][j]=='.'&&j&&((S>>(j-1))&1)){
					for(int k=0;k<K;k++) qmo(f[o][S^(1<<(j-1))][k+1]+=f[p][S][k]-mod);
				}
			}
		}
		o^=1,p^=1;
	}
	int res=0;
	for(int j=0;j<=K;j++){
		int w=1ll*C[cnt-2*j][2*(K-j)]*fac[2*(K-j)]%mod*C[K][j]%mod*fac[j]%mod*f[p][0][j]*_k[j]%mod;
		if(j&1) qmo(res-=w);
		else qmo(res+=w-mod);
	}
	printf("%d\n",res);
}
int main(){
	init(144);
	int T;
	scanf("%d",&T);
	while(T--) sol();
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 3908kb

input:

2
2 2 2
..
..
4 4 3
X.X.
....
.X..
...X

output:

8
347040

result:

ok 2 number(s): "8 347040"

Test #2:

score: -100
Wrong Answer
time: 134ms
memory: 6256kb

input:

96
1 144 8
................................................................................................................................................
144 1 31
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
....

output:

847044751
483639182
899976468
-520842148
0
0
899423610
-200577089
589295509
169129272
-881056367
681705068
788215372
868023441
821890538
255484433
692309075
909664790
266902493
1213362141
829040673
77637449
1614444435
1099996522
349503320
1419196627
990694205
-137648477
477633286
989152677
981420655...

result:

wrong answer 1st numbers differ - expected: '517668733', found: '847044751'