#P3492.第1题-基于决策树预判资源调配优先级

第1题-基于决策树预判资源调配优先级 - problem_ide - CodeFun2000

主要是把题看懂

python 复制代码
class Node:
    def __init__(self,feature_index,threshold,left,right,label):
        self.feature_index = feature_index
        self.threshold = threshold
        self.left = left
        self.right =right
        self.label =label


f,m,n = map(int,input().split())

tree = []

for _ in range(m):
    fi,thr,l,r,lbl = input().split()

    tree.append(Node(int(fi),float(thr),int(l),int(r),int(lbl)))

for _ in range(n):
    features = list(map(float,input().split()))

    current = 0

    while True:
        node = tree[current]
        if node.feature_index == -1:
            print(node.label)
            break
        
        if features[node.feature_index] <= node.threshold:
            current = node.left
        else:
            current = node.right
    
相关推荐
To_OC7 小时前
LC 131 分割回文串:刚学回溯时,我连怎么切字符串都想不明白
javascript·算法·leetcode
旖-旎8 小时前
LeetCode 518:零钱兑换||(完全背包)—— 题解
c++·算法·leetcode·动态规划·背包问题
To_OC9 小时前
LC 42 接雨水:暴力超时卡半天?前后缀数组一用就通了
javascript·算法·leetcode
delishcomcn9 小时前
AI视觉识别+分切算法:电化铝缺陷检测与裁切一体化解锁
人工智能·算法
触底反弹10 小时前
深入理解大模型采样:Temperature、Top-K、Top-P 的原理与实战
人工智能·算法·面试
大模型码小白10 小时前
【Python零基础教程】继承、多态与魔法函数:面向对象编程三大核心特性详解
java·大数据·开发语言·人工智能·python·ai编程
雪碧聊技术10 小时前
力扣 LCR 091. 粉刷房子 —— 动态规划入门详解
算法·动态规划
麻雀飞吧10 小时前
最新量化学习路径,交易认知和技术实现要并行
人工智能·python
CV-Climber13 小时前
检索技术的实际应用
人工智能·算法