QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#716504#2549. King's PalaceTx_LcyWA 0ms3560kbC++14950b2024-11-06 15:24:542024-11-06 15:24:55

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 15:24:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3560kb
  • [2024-11-06 15:24:54]
  • 提交

answer

//A tree without skin will surely die.
//A man without face will be alive.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ull unsigned long long
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define per(i,j,k) for(int i=j;i>=k;--i)
int const N=2.1e3+10;
int n,m,a[N],b[N],x[N],y[N];
ull an[25][3],val[25];map<ull,int>mp[25];
inline int dfs(int x,ull g){
	if (x<0) return 1;
	if (mp[x].count(g)) return mp[x][g];
	int sm=0;
	rep(i,0,2) if (x==n-1 || (!(g>>(x*3+i)&1)))
		sm+=dfs(x-1,(g&val[x])|an[x][i]);
	return mp[x][g]=sm;
}
inline void solve(){
	cin>>n>>m;
	if (n==1) return cout<<3<<'\n',void();
	rep(i,1,m){
		cin>>a[i]>>x[i]>>b[i]>>y[i],--a[i],--b[i];
		an[b[i]][y[i]]|=1ull<<(a[i]*3+x[i]);
	}
	rep(i,0,n-1) val[i]=(1ull<<(3*i))-1;
	cout<<dfs(n-1,0)<<'\n';
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int t=1;
	// cin>>t;
	while (t--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3560kb

input:

2 3
1 R 2 R
1 G 2 R
1 B 2 G

output:

9

result:

wrong answer expected '6', found '9'