QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#716236#2549. King's PalaceBINYUWA 0ms3692kbC++14787b2024-11-06 14:43:262024-11-06 14:43:26

Judging History

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

  • [2024-11-06 14:43:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3692kb
  • [2024-11-06 14:43:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
const int N = 22,M = 10000;
int n,m,a[M + 5],b[M + 5],c[M + 5],d[M + 5],p[N + 5],flag[N + 5][3];
vector <pair <int,int> > v[N + 5][3];
ll dfs(int x)
{
	if(x == n + 1)return 1;
	int cnt = 0;ll res = 0;
	for(int i = 0;i < 3;i++)
	{
		p[x] = i;
		if(flag[x][i])continue;
		if(!v[x][i].size())cnt++;
		else
		{
			for(auto now : v[x][i])
				flag[now.first][now.second]++;
			res += dfs(x + 1);
			for(auto now : v[x][i])
				flag[now.first][now.second]--;
		}
	}
	if(cnt)p[x] = -1,res += cnt * dfs(x + 1);
	return res;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i = 1;i <= m;i++)
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]),
		v[a[i]][b[i]].push_back({c[i],d[i]}); 
	cout<<dfs(1);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

9

result:

wrong answer expected '6', found '9'