BZOJ4443[Scoi2015][小凸玩矩阵] 二分图最大匹配+二分

【bzoj4443】【[Scoi2015]小凸玩矩阵】二分+二分图最大匹配 (上不了p站我要死了,侵权度娘背锅) Description 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最小值是多少。 Input 第一行给出三个整数N,M,K 接下来N行,每行M个数字,用来描述这个矩阵 Output 如题 S 阅读详情

题目链接


题解:二分第K大的值,把小于这个值的边加入图中,再求最大匹配,看能不能找出n-k+1个数<=mid
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 305 ;

int lk [N] , w [N] [N] , vis [N] ;
int n , m , mid , k ;

bool find ( int u ){
    for ( int i = 1 ; i <= m ; ++ i )
        if ( w [u] [i] <= mid && ! vis [i] ) {
            vis [i] = 1 ;
            if ( lk [i] == 0 || find ( lk [i] ) ){
                lk [i] = u;
                return true ;
            }
        }
    return false ;  
}

bool check (){
    int ans = 0 ;
    memset ( lk, 0 , sizeof ( lk ) );
    for ( int i = 1 ; i <= n ; ++ i ){
        memset ( vis , 0 , sizeof ( vis ) );
        ans += find ( i ) ;
    }
    return ans > n - k ;
}

int main() {
    scanf ( "%d%d%d", &n , &m , &k );
    for ( int i = 1 ; i <= n ; ++ i )
        for ( int j = 1; j <= m ; ++ j )
            scanf ( "%d" , &w [i] [j] );
    int l = 1 , r = 1e9 , ans = 1;
    while ( l <= r ) {
        mid = ( l + r ) >> 1;
        if ( check () ) r = mid - 1 , ans = mid ;
        else l = mid + 1; 
    }
    printf ( "%d" , l ) ;
    return 0 ;
}
华为OD机试真题2025双机位C卷 Python&JS 实现【卡牌游戏】 小明正在尝试一种新的牌游戏。游戏规则只如下:首先,小明拿到一张写有数字m的牌。 然后,他会拿到另外n张牌,上面分别写有不同的数字,牌排成一排。小明的目标是从这排牌中找到一串连续的牌,这些牌上数字的总和可以被 m整除。你的任务是判断小明是否可以完成这个目标。 阅读详情

相关推荐

Miniconda入门:在CentOS上的安装、基本操作、目录结构、卸载

Miniconda是一个 免费的 轻量级的 conda安装程序 它只包含conda、Python、pip、zlib等基础的文件和依赖包 使用conda install命令可从Anaconda存储库中安装额外的conda包 简介 下载 安装 基本操作 虚拟环境的操作 包的操作 目录结构 卸载

ArYe 1万+

【BZOJ4443】[Scoi2015]小凸玩矩阵 二分+二分图最大匹配

【BZOJ4443】[Scoi2015]小凸玩矩阵 Description 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最小值是多少。 Input 第一行给出三个整数N,M,K 接下来N行,每行M个数字,用来描述这个矩阵 Output ...

weixin_30458043的博客 96

保姆级教程:用Altium Designer 24从零画一块PCB(附完整库文件与避坑清单)

本文提供了一份详细的Altium Designer 24(AD24)PCB设计教程,从工程创建到最终文件输出,涵盖元件库管理、原理图设计、PCB布局布线等全流程。特别适合初学者,包含STM32最小系统板的实战案例,附完整库文件和避坑清单,帮助用户快速掌握AD24的核心功能与技巧。

weixin_27697385的博客 258

[bzoj4443][Scoi2015]小凸玩矩阵(二分答案+二分图最大匹配)

【题目链接】http://www.lydsy.com/JudgeOnline/problem.php?id=4443 【解题思路】二分答案转化为判定性问题,将数值小于等于二分值的节点拿去建二分图,跑一边最大匹配即可 【呆马】#include<cstdio> #include<algorithm> #include<cmath> #include<cstdlib> #include<iostrea

S_G_G的博客 1072

Ubuntu上安装Claude Code CLI:从环境配置到排错全攻略

在Linux开发环境中,命令行工具的安装与配置是开发者绕不开的基础技能。无论是AI编程助手还是其他CLI工具,其运行都依赖于正确的运行时环境和包管理机制。以Node.js生态为例,版本管理器nvm解决了多版本切换的痛点,npm则负责全局包的安装与依赖解析。理解PATH环境变量的执行逻辑、全局bin目录的作用以及权限控制,是排查“命令找不到”或“EACCES”错误的关键。这些基础知识应用广泛,从本地开发到服务器部署都至关重要。本文以Ubuntu系统上安装Anthropic的Claude Code CLI为例,

weixin_28842367的博客 279

vivado:差分信号和单端信号 的相互转换 IBUFDS OBUFDS

FPGA能处理的都是单端信号,但有些输入信号是差分的,这时候就需要把差分信号转为单端信号。

qq_52137732的博客 1万+

BZOJ4443(Scoi2015)[小凸玩矩阵]--二分+二分图最大匹配

bozj4443

Greninja的博客 880

Nvivo12新手避坑指南:从安装到编码的完整流程(附实战案例)

本文为Nvivo12新手提供了从软件安装、初始设置到数据导入和编码分析的完整避坑指南。通过一个“校园欺凌现象的学生访谈研究”实战案例,详细拆解了处理中文文本、创建项目结构、执行手动编码及高级查询等关键步骤,帮助研究者避开常见错误,快速上手并高效完成质性数据分析。

resnet7explorer的博客 330

[BZOJ]4443 [SCOI2015] 小凸玩矩阵 二分答案 + 二分图最大匹配

4443: [Scoi2015]小凸玩矩阵 Time Limit: 10 Sec  Memory Limit: 128 MB Submit: 1322  Solved: 622 [Submit][Status][Discuss] Description 小凸和小方是好朋友,小方给小凸一个N*M(N Input 第一行给出三个整数N,M,K 接下来N行,每行M个数

Le Petit Prince 442

PCL 最小生成树用于法向量定向【2025最新版】

PCL 最小代价生成树用于点云法向量的定向。博客长期更新,本文最近更新时间为:2025年9月15日。

点云侠的博客 2076

lammps教程:聚合物压缩,避免“bond atoms missing”

如果使用ms建模,聚合物的链会伸出到盒子外面,在导出data文件后,盒子外面的原子被周期性算法折叠进盒子对面,这就造成了边界附近的bond原子可能被分布到了盒子的两侧。并且,这个data文件不能使用npt系综进行压缩,npt系综必须使用周期性边界,在压缩时,bond原子同样会移动到对面的边界。所以,最好的解决办法是使用一个反射墙墙进行压缩,设置一个反射墙墙既可以实现压缩效果,也可以组织原子跨越box边界移动到对面。解决这个问题的原则只有一个:导出data时确保所有的bond原子没有跨越边界。

lammps_jiayou的博客 3834

【bzoj4443】[Scoi2015]小凸玩矩阵 二分+二分图最大匹配

题目描述 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最小值是多少。 输入 第一行给出三个整数N,M,K 接下来N行,每行M个数字,用来描述这个矩阵 输出 如题 样例输入 3 4 2 1 5 6 6 8 3 4 3 6 8 6 3 ...

weixin_30736301的博客 111

open3d将某一时间序列下的彩色图和深度图批量转换成点云(python)

必备条件需要3D相机生成的彩色图及深度图,注意要将深度图与彩色图对齐(一般3D相机自带对齐算子),以及3D相机的彩色图内参(相机自带内参获取功能)。有了此彩色图、对齐后的深度图以及相机内参就能使用open3d生成彩色点云了.

吾名招财的博客 327

BZOJ 4443: [Scoi2015]小凸玩矩阵 二分图最大匹配+二分

题目链接: http://www.lydsy.com/JudgeOnline/problem.php?id=4443 题解: 二分答案,判断最大匹配是否>=n-k+1; 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<vector&...

weixin_30402085的博客 119

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

深度学习工具包 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")

【bzoj4443】[Scoi2015]小凸玩矩阵 二分+二分图匹配

二分答案 判断是否能取出N-K+1个小于等于ans的数 但是能取出N-K+1个小于等于ans的数,不代表能取出K个大于等于ans的数呀 注意,最后得到的ans是最小的存在N-K个比它小的数的数 如果连最小的ans都取不到,那么更大的ans也取不到呀 #include #include #include #include #include #include #define ma

Oxer的专栏 1935

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

bzoj 4443 [Scoi2015]小凸玩矩阵

题面 https://www.lydsy.com/JudgeOnline/problem.php?id=4443 题解 水题 二分答案 然后跑二分图匹配 如果匹配数量大于等于那么可行 匈牙利比较好写 Code 1 #include<bits/stdc++.h> 2 using namespace std; 3 typedef long lon...

aozhuan8489的博客 176

[SCOI2015]小凸玩矩阵

题目:洛谷P4251、BZOJ4443。 题目大意:有一个\(n\times m(n\leq m)\)的矩阵,要选出n个数,使得这n个数既不同行也不同列。问选的数中第k大的数最小可以是多少。解题思路:首先二分答案,然后只要判断,是否能选择至少n-k+1个数,它们的值都不超过当前的答案。然后很简单,对每个小于等于当前答案的数,行向列连边。做二分图匹配即可。时间复杂度\(n^2\log\)...

177

BZOJ 4443: [Scoi2015]小凸玩矩阵

https://www.lydsy.com/JudgeOnline/problem.php?id=4443 看到第K大的最小,想到二分 那么二分一个第K大值mid,小于等于mid的元素全都连边,然后求二分图最大匹配,如果匹配的超过n-k+1,那么就是可行的 卧槽我今天突然发现vis数组是m对于右边的点,所以长度应该是m,而不是n。。。。WA了好久 #include<bits/std...

binarycopycode 214

Luogu 4251 [SCOI2015]小凸玩矩阵

BZOJ 4443 二分答案 + 二分图匹配 外层二分一个最小值,然后检验是否能选出$n - k + 1$个不小于当前二分出的$mid$的数。对于每一个$a_{i, j} \geq mid$,从$i$向$j + n$连一条边,然后跑二分图最大匹配即可。 菜的很,二分图匹配都写不对…… 注意数组要开到双倍$n$。 时间复杂度$O(nmlogn)$。 Code: #in...

dashu497731727的博客 118

BZOJ4443: [Scoi2015]小凸玩矩阵(二分加二分图匹配)

4443: [Scoi2015]小凸玩矩阵 Time Limit: 10 Sec Memory Limit: 128 MB Description 小凸和小方是好朋友,小方给小凸一个N*M(N&amp;lt;=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最小值是多少。 Input 第一行给出三个整数N,M,K 接下来...

苟为蒟蒻又何妨 310

bzoj4443: [Scoi2015]小凸玩矩阵(二分+二分图匹配)

题目传送门 不错的题啊。解法: 第一眼看上去:二分!!! 求第K大的最小值嘛。 跟求最大的尽量小有什么区别。 一看感觉就是二分。。 继续想: 要找行和列不同的点? 这题怎么跟我之前做过的一道题这么像呢。。(bzoj1059) 二分图匹配嘛。我做过的。。那么我们就二分最小值咯。然后大于等于他的点我们给行跟列一个匹配关系。 然后跑一次二分图匹配,看一下是否>=K个,这道题就解决了,美

Hanks_o的博客 441

[二分+二分图匹配]BZOJ 4443: [Scoi2015]小凸玩矩阵 题解

(传送门)题目大意题目说的很清楚,不说了。解题分析学过二分图匹配的一定做过一道题,要求每行每列只能选一个问最多能拿多少个,这个题就是行向列连边然后二分图匹配就行。那么这道题是多了一个K大值最小,也可以看做n-K+1大值最小,那么最大最小就是二分答案,那么验证,就需要保证所有低于mid的是合法可以连边,如果最后可以选出n-K+1个数小于mid,那么因为n<=m,所以剩下来的可以任意选都合法,也就是可以

Wflower的Blog //What are you waiting for? 313

BZOJ 4443 [Scoi2015]小凸玩矩阵——二分+二分图匹配

4443: [Scoi2015]小凸玩矩阵题目描述 小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最小值是多少。 输入 第一行给出三个整数N,M,K 接下来N行,每行M个数字,用来描述这个矩阵 输出 如题 解题思路 看到这样选择方式马上就会想到二分图匹配,但是因

CHN_JZ的博客 810

BZOJ 4443 小凸玩矩阵 (网络流 dinic 二分)

4443: [Scoi2015]小凸玩矩阵Time Limit: 10 Sec Memory Limit: 128 MB Description小凸和小方是好朋友,小方给小凸一个N*M(N<=M)的矩阵A,要求小秃从其中选出N个数,其中任意两个数字不能在同一行或同一列,现小凸想知道选出来的N个数中第K大的数字的最小值是多少。 Input第一行给出三个整数N,M,K 接下来N行,每行M个数字,

w4149 473
上一篇: BZOJ2599 [IOI2011] [Race] 点分治
下一篇: BZOJ4950 [Wf2017][Mission Improbable] 二分图匹配
Venishel
博客等级 码龄10年 32粉丝 190原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值