码风良好代码求调
查看原帖
码风良好代码求调
499140
3wykx楼主2023/11/13 13:50

30pts,最近脑袋瓜不太灵光,被橙题卡半天

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,ans=0;
int a[10][7];
bool check(int w[]) {
	for(int i=1; i<=n; i++) {
		int cnt=0,flag[7]= {0};
		for(int j=1; j<=5; j++) {
			if(a[i][j]!=w[j]) {
				cnt++;
				flag[j]=1;
			}
		}
		if(cnt==1||cnt==0)continue;
		else if(cnt==2) {
			bool biaoji=0;
			for(int j=1; j<=4; j++) {
				if(flag[j]==1&&flag[j+1]==1) {
					for(int pos=1; pos<=9; pos++) {
						int nwa,nwb;
						nwa=(a[i][j]+pos)%10,nwb=(a[i][j+1]+pos)%10;
						if(nwa==w[j]&&nwb==w[j+1])
							biaoji=1;
					}
				}
			}
			if(biaoji==0)return false;
		} else return false;
	}
	return true;
}
signed main() {
	//freopen("lock.in","r",stdin);
	//freopen("lock.out","w",stdout);
	scanf("%lld",&n);
	for(int i=1; i<=n; i++)
		for(int j=1; j<=5; j++)
			scanf("%d",&a[i][j]);
	int k[6]= {0};
	while(k[1]!=10) {
		if(check(k))
			ans++;
		if(k[5]+1<=9)k[5]++;
		else if(k[4]+1<=9)k[4]++,k[5]=0;
		else if(k[3]+1<=9)k[3]++,k[4]=k[5]=0;
		else if(k[2]+1<=9)k[2]++,k[3]=k[4]=k[5]=0;
		else k[1]++,k[2]=k[3]=k[4]=k[5]=0;
	}
	cout<<ans<<endl;
	return 0;
}
2023/11/13 13:50
加载中...