Non-Transitive Dice(暴力/dfs/水)

题目
题意:给定两个四面筛子A,B,每个面上的数字取值为1到10。问是否存在另一个筛子C,使得A>B,B>C,C>A或B>A,A>C,C>B。筛子X>筛子Y,当且仅当投掷筛子X,得到的数字比筛子Y大,的概率更大。
思路:暴力,枚举所有的筛子,看是否有满足的。

#include<bits/stdc++.h> 
using namespace std;
const int maxn = 110;
#define ll long long
const int num = 4;

int a[num], b[num], c[num];
int res;
int beat(int a[], int b[]) {
	int x = 0, y = 0;
	for (int i = 0; i < num; ++i) {
		for (int j = 0; j < num; ++j) {
			if (a[i] > b[j]) ++x;
			else if (a[i] < b[j]) ++y;
		}
	}
	if (x == y) {
		return 0;
	}
	return x > y ? 1 : -1;
}

void print(int a[]) {
	for (int i = 0; i < num; ++i) {
		printf("%d ", a[i]);
	}
	printf("--\n");
}

bool dfs(int deep) {
	if (deep == 4) {
		bool flag = false;
		if (res == 1) {
			flag = (beat(c, a) == 1) && (beat(b, c) == 1);
		} else {
			flag = (beat(c, b) == 1) && (beat(a, c) == 1);
		}
//		if (flag) {
//			print(c);
//		}
		return flag;
	}
	for (int i = 1; i<= 10; ++i) {
		c[deep] = i;
		if (dfs(deep+1)) {
			return true;
		}
	}
	return false;
}
void solve() {
	for (int i = 0; i < num; ++i) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < num; ++i) {
		scanf("%d", &b[i]);
	}
	res = beat(a, b);
//	printf("res %d\n", res);
	if (!res) {
		printf("no\n");
		return;
	}
	bool flag = dfs(0);
	
	printf("%s\n", flag ? "yes" : "no");
	
}
int main() {
	
	int t;
	scanf("%d", &t);
	while (t--) {
		solve();
	}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Description: An attempt was made to call a method that does not exist. The attempt was made from the following location: org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory.getPoolConfig(LettuceConnectionConfiguration.java:207) The following method did not exist: 'void org.apache.commons.pool2.impl.GenericObjectPoolConfig.setMaxWait(java.time.Duration)' The calling method's class, org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory, was loaded from the following location: jar:file:/D:/Developing%20learning%20software/apache-maven-3.9.2-bin/nfv/org/springframework/boot/spring-boot-autoconfigure/3.1.2/spring-boot-autoconfigure-3.1.2.jar!/org/springframework/boot/autoconfigure/data/redis/LettuceConnectionConfiguration$PoolBuilderFactory.class The called method's class, org.apache.commons.pool2.impl.GenericObjectPoolConfig, is available from the following locations: jar:file:/D:/Developing%20learning%20software/apache-maven-3.9.2-bin/nfv/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar!/org/apache/commons/pool2/impl/GenericObjectPoolConfig.class The called method's class hierarchy was loaded from the following locations: org.apache.commons.pool2.impl.GenericObjectPoolConfig: file:/D:/Developing%20learning%20software/apache-maven-3.9.2-bin/nfv/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar org.apache.commons.pool2.impl.BaseObjectPoolConfig: file:/D:/Developing%20learning%20software/apache-maven-3.9.2-bin/nfv/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar org.apache.commons.pool2.BaseObject: file:/D:/Developing%20learning%20software/apache-maven-3.9.2-bin/nfv/org/apache/commons/commons-pool2/2.6.0/commons-pool2-2.6.0.jar Action: Correct the classpath of your application so that it contains compatible versions of the classes org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration$PoolBuilderFactory and org.apache.commons.pool2.impl.GenericObjectPoolConfig
07-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值