QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#620525#2549. King's PalaceUncleEricWA 0ms3588kbC++141.1kb2024-10-07 18:48:272024-10-07 18:48:28

Judging History

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

  • [2024-10-07 18:48:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-10-07 18:48:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int n,m;
vector<int> imp[25][5][2];
bool use[10005],nb[25][5];

inline int r(char x){
	if(x=='R')return 0;
	if(x=='G')return 1;
	return 2;
}

inline long long dfs(int pos){
	if(pos>n){
		return 1;
	}
	bool cg[3]={1,1,1};
	for(int i=0;i<3;i++){
		for(int j:imp[pos][i][1]){
			if(!use[j]){
				cg[i]=0;break;
			}
		}
	}
	if(!(cg[0]+cg[1]+cg[2]))return 0;
	int cnt=0;
	for(int i=0;i<3;i++){
		if(cg[i]&&!nb[pos][i]){
			cnt++;
		}
	}	
	long long ans=cnt?dfs(pos+1)*cnt:0;
	for(int i=0;i<3;i++){
		if(cg[i]&&nb[pos][i]){
			for(int j:imp[pos][i][0]){
				use[j]=0;
			}ans+=dfs(pos+1);
			for(int j:imp[pos][i][0]){
				use[j]=1;
			}
		}
	}
	return ans;	
}

int main(){
//	freopen("paint.in","r",stdin);
//	freopen("paint.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b,x,y;char xx,yy;cin>>a>>xx>>b>>yy;
		x=r(xx),y=r(yy);
		imp[a][x][0].push_back(i);
		imp[b][y][1].push_back(i);
		nb[a][x]=1;
	}
	cout<<dfs(1);
	return 0;
}

详细

Test #1:

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

input:

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

output:

4

result:

wrong answer expected '6', found '4'