考场ST1代码记不全了,民间70求调
  • 板块灌水区
  • 楼主Walrus
  • 当前回复16
  • 已保存回复16
  • 发布时间2023/10/21 21:32
  • 上次更新2023/11/2 12:07:33
查看原帖
考场ST1代码记不全了,民间70求调
908424
Walrus楼主2023/10/21 21:32

rt

#include <bits/stdc++.h>
using namespace std;
int a[10][10], b[10], c[10], n, ans;
void dfs(int x) {
	if(x == 6) {
		bool ok = 1;
		for(int i = 1;i <= n;i++) {
			int tot = 0, id1, id2;
			bool xyk = 0;
			for(int j = 1;j <= 5;j++) {
				if(a[i][j] != c[j]) {
					++tot;
					if(tot == 1)
						id1 = j;
					if(tot == 2)
						id2 = j;
				}
			}
			if(tot == 1)
				continue;
			if(tot == 0 || tot > 2 || id1 + 1 != id2 || id1 + 1 == id2 && a[i][id1] - c[id1] != a[i][id2] - c[id2]) {
				ok = 0;
				break;
			}
		}
		if(ok) 
			++ans;
		return;
	}
	for(int i = 0;i <= 9;i++) {
		c[x] = i;
		dfs(x + 1);
	}
}
int main() {
//	freopen("lock.in", "r", stdin);
//	freopen("lock.out", "w", stdout);
	cin >> n;
	for(int j = 1;j <= n;j++) 
		for(int i = 1;i <= 5;i++)
			cin >> a[j][i];
	if(n == 1) {
		cout << 81;
		return 0;
	}
	dfs(1);
	cout << ans;
	return 0;
}
/* 
2
1 2 3 5 5
1 2 3 5 1
*/
2023/10/21 21:32
加载中...