Poj 2239 Selecting Courses 二分图最大匹配

Go语言集成Ollama本地大模型:gollama库实战指南 在当今的AI应用开发中,大型语言模型(LLM)的集成已成为关键技术。其核心原理是通过API调用,将自然语言处理能力嵌入到各类应用中。从技术价值看,本地化部署的LLM解决了数据隐私、网络延迟和持续成本三大痛点,尤其适合处理敏感数据或对实时性要求高的场景。在工程实践中,开发者常使用专门的客户端库来简化与模型服务的交互,例如通过封装REST API、提供类型安全接口和流式处理支持,从而提升开发效率和代码健壮性。具体到Go语言生态,结合Ollama这一流行的本地大模型运行工具,可以实现完全离线、低延迟的AI功能集成 阅读详情

      Selecting Courses 题意: 一门课在一周可能开设多次,它们都是等价的。一个学生不能在统一时间段同时上两门课。问如何选尽可能多的课。这道题是考查二分图最大匹配,直接按照经典算法实现即可。两位也可以转换成最大流问题。


// http://poj.org/problem?id=2239
// 二分图最大匹配

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

#define MAX_N  310
#define MAX_M  100

bool map[MAX_N][MAX_M];
int  match[MAX_M];
bool use[MAX_N];

int Course;

bool dfs(int p)
{
    int i, t;

    for(int i = 0; i < MAX_M; i++)
    {
        if(map[p][i] && !use[i])
        {
            use[i] = true;

            if(match[i] == -1 || dfs(match[i]))
            {
                match[i] = p;
                return true;
            }
        }
    }

    return false;
}


int main()
{
    //freopen("data.txt", "r", stdin);

    while(cin >> Course)
    {
        memset(map, false, sizeof(map));
        memset(match, -1, sizeof(match));

        for(int i = 0; i < Course; i++)
        {
            int pari;
            int day;
            int classTime;

            cin >> pari;
            for(int j = 0; j < pari; j++)
            {
                    cin >> day >> classTime;

                    int classNum = (day - 1) * 12 + (classTime - 1);

                    map[i][classNum] = true;
            }
        }

        int selectNum = 0;
        for(int i = 0; i < Course; i++)
        {
            memset(use, false, sizeof(use));

            if(dfs(i))
                selectNum++;
        }

        cout << selectNum << endl;
    }

    return 0;
}


Windows版TASSEL5的下载及安装 TASSEL5是一款用于研究表型和基因型关系的软件,由美国康奈尔大学Buckler实验室所研发。,选择Windows环境安装包下载并安装。1.安装成功后TASSEL5界面。 阅读详情

相关推荐

ASReview:基于主动学习的AI文献筛选工具,提升科研效率

主动学习是机器学习的一个重要分支,其核心原理是让算法能够主动选择最有价值的数据进行标注,从而以更低的成本获得更好的模型性能。这一技术通过人机协作的闭环流程,显著提升了数据标注和模型训练的效率和精度。在工程实践中,主动学习尤其适用于数据标注成本高昂或数据类别不平衡的场景,例如医学影像分析、自然语言处理中的文本分类以及推荐系统的冷启动问题。通过优先标注模型最不确定的样本,它能够有效解决传统机器学习面临的冷启动和数据稀疏性挑战。本文聚焦的ASReview项目,正是将主动学习原理应用于系统文献综述这一具体场景,通过

weixin_28725959的博客 441

poj2239 - Selecting Courses

想看更多的解题报告: http://blog.csdn.net/wangjian8006/article/details/7870410                                   转载请注明出处:http://blog.csdn.net/wangjian8006 题目大意:在大学里有许许多多的课程,现在小明需要去选择课程,他是一个爱学习的人,所以想尽可能多的选择课

贰圣 2929

IntelliJ IDEA 2025.1 + Gradle 镜像配置避坑指南:解决依赖下载慢的终极方案

本文针对IntelliJ IDEA 2025.1开发环境中Gradle依赖下载缓慢的问题,提供了详细的镜像配置避坑指南。通过解析Gradle依赖解析机制,重点指导如何正确配置阿里云等国内镜像仓库,并分享验证配置生效、排查常见错误及高级优化技巧,旨在彻底解决依赖下载难题,提升开发效率。

weixin_28835551的博客 537

POJ2239_Selecting Courses(二分图最大匹配)

解题报告 题目传送门 题意: 每天有12节课,一周上7天,一门课在一周有多天上课。求一周最多上几节课。 思路: 把课程看成一个集合,上课的时间看成一个集合,二分图就出来了。 #include #include #include using namespace std; int n,day[10][15],mmap[500][500],vis[500],cnt,pre[500];

_nplus 1496

攻防世界 misc题GFSJ1129-【您看我还有机会吗?】

我们发现了隐藏内容,一开始我以为那个英文就是flag,提交后发现不对,然后我想只有一张图片然后图片上的隐写内容又不是flag,那必定还有什么文件被隐藏了,于是我们打开VMware并启动Ubuntu,使用binwalk分析一下有没有隐藏文件,我们要在Terminal中分析,如下。我们发现里面有一个flag.txt文件,我们尝试提取里面内容,但发现又要密码,我们想起了之前图片上的隐藏内容,我们将那段英文输入(包括空格和符号,在VMware中输入密码不会有显示,你看到的就像没输入一样),然后我们看到如下。

大数据专业,关注 AI 安全与数学建模。记录 Web 安全、对抗攻击、隐私保护等安全实践,以及从经典模型到智能方法的建模思考。用数学思维理解 AI,用 AI 方法反哺安全与建模。 1109

Matlab双目相机标定

1 概述 现在有许多双目相机在出厂时就已经标定好了,用户拿到手后可以直接使用,例如Intel Realsense系列。但是有些相机出厂的时候并没有完成标定工作,因而这个时候就需要我们自己来标定。由于笔者曾改装过一个双目相机,最远可以测至50m,因此有一定的心得体会想给大家分享一下。本文主要介绍双目相机标定的整个过程,以及导出标定数据的方法。 相机标定主要分为手动标定和自动标定,手动标定比较繁琐,这里主要介绍基于matlab工具箱的自动标定方式来对双目相机进行标定。具体的相关标定细节也可以参照这篇博客:m

weixin_46133643的博客 2万+

poj Selecting Courses(二分图最大匹配)

题目连接:http://poj.org/problem?id=2239 题意:在大学里能选N门课程,一个星期七天,一天12节课,但是在上课的时间会产生冲突。 已知每节课的上课时间,求最多能选多少门课 典型二分图最大匹配,不解释··········· 匈牙利算法 #include #include #include #include using namespace std; str

一点一滴 735

在 SAP BTP 中通过 MTA 自动创建 Service Broker 的原理与实战

本文探讨了如何在SAP BTP的Cloud Foundry环境中通过MTA部署自动创建和注册Service Broker。传统手动注册方式存在依赖管理员、环境一致性差等问题。通过MTA部署可实现自动化Broker注册,利用占位符生成安全凭证,并确保平台端与应用端认证一致。文章详细解析了关键配置参数,包括create-service-broker标志、Broker名称、认证凭据和访问URL的设置方法。这种基础设施即代码(IaC)方式能提升DevOps实践水平,使服务注册成为应用部署流水线的有机组成部分。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 205

poj 2239 Selecting Courses 【二分图最大匹配】

Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8998   Accepted: 4005 Description It is well known that it is not eas

世界很大 709

OpenClaw实战系列·进阶特辑02:多智能体协同——打造企业级AI中台

**企业级AI中台面临多Agent协同的挑战,本文提出基于多智能体协同的解决方案。通过分析单Agent的局限性(上下文溢出、专业度稀释等)和多Agent的核心优势(任务专注度、故障隔离等),提出三种协作架构模式(指挥型、联邦型、点对点型),并强调人格化设计的重要性。文章详细介绍Agent间通讯机制(同步/异步会话、文件系统协作)和"身脑分离"的解耦架构设计,提供可落地的企业级AI中台实施方案。

PeterPan的博客 499

机器人的“大脑”进化论:从专用控制器到高性能SoC的异构计算时代

摘要:随着AI与机器人技术融合,高性能芯片成为机器人智能化的关键。本文分析了机器人对芯片的核心需求,包括多模态数据处理、实时控制和智能决策能力。系统级芯片(SoC)因集成CPU、GPU/NPU等模块而成为主流选择。市场呈现分层格局:中低端设备(如扫地机器人)采用"MCU+轻量SoC"方案,满足基础功能;高端机器人则依赖"高性能SoC+独立GPU"处理复杂任务。除主控芯片外,完整的机器人系统还需传感器接口、驱动、通信等配套芯片。未来,芯片技术的进步将持续推动机器人智能化

致力于lidar应用开发 86

POJ 2239Selecting Courses(二分图最大匹配之最大匹配)

题目地址:http://poj.org/problem?id=2239 还是jingyanbuzua

scf0920 1002

MIKE水动力笔记5_建立水动力模型

前文已经讲了如何制作网格文件(.mdf文件),这一博文就讲如何建立水动力模型。

晏长街的博客 3万+

POJ2239 Selecting Courses【二分图最大匹配】

题目大意: 学校总共有N门课程,并且学校规定每天上12节可,一周上7天。给你每门课每周上的次数,和哪一天哪一节 课上的。如果有多门课程在同一天同一节课上,那么你只能选择其中一门。那么问题来了:最多能同时选多少 门课而不发生冲突呢。 输入说明: 先给你一个N,表示有N门课。接下来N行,每行第一个数字x,表示这门课每周上几节。接下来是x对数。第 一个数D表示是这一周哪一天上的,第二个数C表示是这一天哪一节课上的。 思路: 将这道题来看做二分图匹配问题。建立一个二分图,一边代表课程,一边代表某一节课(将一周7

程序员充电站(itcharge) 1037

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

POJ2239 Selecting Courses(二分图最大匹配)

题目链接 N节课,每节课在一个星期中的某一节,求最多能选几节课 好吧,想了半天没想出来,最后看了题解是二分图最大匹配,好弱 建图: 每节课 与 时间有一条边 1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <cstring...

apk6909的博客 132

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

poj Selecting Courses 2239 (二分图最大匹配)

Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9853   Accepted: 4434 Description It is well known that it is not easy to select courses in t

yanghui07216的博客 397

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

POJ 2239 Selecting Courses G++ 二分图最大匹配 背

#include <iostream> #include <vector> #include <cstring> using namespace std; //抄博友程序 看博友好分析 二分图最大匹配 背 vector<int> G[10001]; int link[10001]; int vis[10001]; bool ...

woniupengpeng的专栏 157

poj 2239 Selecting Courses 二分图最大匹配

链接:http://poj.org/problem?id=2239 题意:又是选课!N种课程,每种课程在不同时间可以选择,总共有7天*12节的时间可以选择课程,问最多可以选多少种课。 思路:建图。X区为12*7个结点,Y区为N种课,直接求二分最大匹配即可。 代码: #include #include #include #include #include #include #in

看曙光 1262

poj2239 Selecting Courses --- 二分图最大匹配

匈牙利算法模板题 有n门课程,每门课程可能有不同时间,不同时间的课程等价。 问不冲突的情况下最多能选多少门课。 建立二分图,一边顶点表示不同课程,另一边表示课程的时间(hash一下)。 #include #include #include #include #include #include #include #include #include #defi

Unknown 712

POJ 2239 Selecting Courses(二分图最大匹配,模板题)

题目意思: 规定每周每天有 12 节课,先给出 n 个课程,以及这 n 个课程在第 p 天的第 q 节上,如果几个课都在同一天的同一节上, 那么需要选择其中一个,不能选择多个课程,求一周最多能上几节课 本题要点: 1、二分图最大匹配的模板题。 左部的点表示课程号(1 ~ 300), 右部的点 表示上课的时间段 (1 ~ 84)。 因为MaxN = 310, 直接用邻接矩阵来存储图, a[x][y] = 1 表示课程x 在时间段 y可以上课。 2、然后套用 增广路算法来计算二分图的最大匹配。 3、 第 p 天

qq_38232157的博客 221

Selecting Courses(poj2239,匈牙利算法求二分图最大匹配入门)

Selecting Courses Time Limit:1000MS Memory Limit:65536K Total Submissions:11917 Accepted:5296 Description It is well known that it is not easy to select courses in the colleg...

ccsu_deer 623

POJ 2239 Selecting Courses(二分图最大匹配)

POJ 2239 Selecting Courses(二分图最大匹配) http://poj.org/problem?id=2239 题意:        在大学里有许许多多的课程,现在小明需要去选择课程,他是一个爱学习的人,所以想尽可能多的选择课程, 在学校里有n个课程,并且在学校规定,每周里的每天有12节课,那么一周就有7*12节课。 如果几个课程都在那d天的那c节课上课,那么你需要

code 966

Selecting Courses(POJ 2239)---二分图最大匹配

题目链接 题目描述 Farmer John completed his new barn just last week, complete with all the latest milking technology. Unfortunately, due to engineering problems, all the stalls in the new barn are differen...

weixin_43960284的博客 211

POJ-2239 Selecting Courses(二分图最大匹配)

题目:POJ-2239 Selecting Courses   题目大意:有个爱学习的学生想选课,现在有n门课,知道每门课的上课次数和每次课的上课时间,只要是有一次课可以上,这个

m0_37772713的博客 267

POJ 2239-Selecting Courses(二分图_最大匹配+哈希建图)

Selecting Courses Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8781   Accepted: 3922 Description It is well known that it is not easy to select courses

Rocky0429 1654
上一篇: K-th string (微软2014实习生及秋令营技术类职位在线测试题)
下一篇: 烦人的幻灯片(类拓扑排序)
liulingbo918
博客等级 码龄14年 3粉丝 12原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值