提高T1这样子写,官方那里测试会不会编译错误
  • 板块学术版
  • 楼主tflsgxy
  • 当前回复8
  • 已保存回复8
  • 发布时间2023/10/21 23:40
  • 上次更新2023/11/2 12:03:51
查看原帖
提高T1这样子写,官方那里测试会不会编译错误
520630
tflsgxy楼主2023/10/21 23:40

如题,我本人在洛谷上测试是满分,可是那个有道小图灵测试显示编译错误,大佬们这是怎么回事,下面附上代码

#include<bits/stdc++.h>
using namespace std;
int lock[10][6];
int mark[100005];
int a,b,c,d,e;
int ans;
long long sum;
int n;
int biao=0;
void dfs1(int step,int num) {
	if(step==6) {
		if(biao==0) return;
		long long h=0;
		for(int i=1,j=1; i<=10000,j<=5; i*=10,j++) {
			h+=lock[num][j]*i;
		}
		if(mark[h]==num-1) mark[h]++;
		return;
	} else {
		for(int i=1; i<=9; i++) {
			int p=lock[num][step];
			int q=lock[num][step]+i;
			q=q%10;
			lock[num][step]=q;
			biao=1;
			dfs1(6,num);
			lock[num][step]=p;
			biao=0;
			dfs1(step+1,num);
		}
	}
}
void dfs2(int step,int num){
	if(step==5){
		if(biao==0) return;
		long long h=0;
		for(int i=1,j=1;i<=10000,j<=5;i*=10,j++){
			h+=lock[num][j]*i;
		}
		if(mark[h]==num-1) mark[h]++;
		return;
	}
	else{
		for(int i=11;i<=99;i+=11){
			int p1=lock[num][step];
			int p2=lock[num][step+1];
			int q1=lock[num][step]+i%10;
			q1=q1%10;
			int q2=lock[num][step+1]+i%10;
			q2=q2%10;
			lock[num][step]=q1;
			lock[num][step+1]=q2;
			biao=1;
			dfs2(5,num);
			lock[num][step]=p1;
			lock[num][step+1]=p2;
			dfs2(step+1,num);
		}
	}
}
int main() {
	freopen("lock.in","r",stdin);
	freopen("lock.out","w",stdout);
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a>>b>>c>>d>>e;
		lock[i][5]=a;
		lock[i][4]=b;
		lock[i][3]=c;
		lock[i][2]=d;
		lock[i][1]=e;
		sum=e+d*10+c*100+b*1000+a*10000;
		mark[sum]=-10;
		dfs1(1,i);
		biao=0;
		dfs2(1,i);
	}
	for(int i=0; i<=99999; i++) {
		if(mark[i]==n){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}
/*
1
0 0 1 1 5

2
2 8 3 5 5
2 8 3 5 1

8
1 1 1 1 1
1 1 1 1 5
1 1 1 1 2
1 1 1 1 3
1 1 1 1 4
1 1 1 1 6
1 1 1 1 7
1 1 1 1 8


*/
2023/10/21 23:40
加载中...