关于ccf评测机
  • 板块灌水区
  • 楼主Mo20
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/10/21 21:43
  • 上次更新2023/11/2 12:07:07
查看原帖
关于ccf评测机
448983
Mo20楼主2023/10/21 21:43

本人在今天下午的csp-s t1中使用了 lock 作为存储输入的变量名,luogu 自测显示ce,求存活概率( 代码如下

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
bool in_place[6];
int a[6][maxn];
int lock[6][10];
int tmp[6];
int cnt,n;
int pl[3];
void dfs(int step)
{
	if(step==6) {cnt++;for(int i=1;i<=5;i++) a[i][cnt]=tmp[i];return;}
	for(int i=0;i<=9;i++) {tmp[step]=i;dfs(step+1);}
}
bool judge2(int x,int y,int p,int q)
{
	if(x-y==p-q) return true;
	if(x-y+10==p-q) return true;
	if(x-y==p-q+10) return true;
	return false;
}
bool judge(int id)
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=5;j++)
		{
			in_place[j]=0;
			if(a[j][id]==lock[j][i]) in_place[j]=1; 
		}
		int tot=0;
		for(int j=1;j<=5;j++) {if(!in_place[j]) {if(tot==2) return false;pl[++tot]=j;}}
		if(!tot) return false;
		if(tot==2) 
		{
			if(abs(pl[1]-pl[2])!=1) return false;
			if(!judge2(a[pl[1]][id],lock[pl[1]][i],a[pl[2]][id],lock[pl[2]][i])) return false;
		}
	}
	return true;
}
int main()
{
	freopen("lock.in","r",stdin);
	freopen("lock.out","w",stdout);
	dfs(1);
	/*for(int i=1;i<=cnt;i++)
	{
		for(int j=1;j<=5;j++)
			cout<<a[j][i]<<' ';
		cout<<endl;
	}*/
	cin>>n;
	for(int i=1;i<=n;i++) for(int j=1;j<=5;j++) cin>>lock[j][i];
	int ans=0;
	for(int i=1;i<=cnt;i++) if(judge(i)) ans++;
	cout<<ans<<endl;	
	return 0;	
}
/*
2
2 8 3 5 5
2 8 3 5 1

*/
2023/10/21 21:43
加载中...