HDOJ 1435 Stable Match(稳定匹配)

Stable Matching Problem稳定匹配问题-----稳定婚姻算法 (一)问题的引出:             有N男N女,每个人都按照他对异性的喜欢程度排名。现在需要写出一个算法安排这N个男的、N个女的结婚,要求两个人的婚姻应该是稳定的。             何为稳定?             有两对夫妻M1 F2,M2 F1。M1心目中更喜欢F1,但是他和F2结婚了,M2心目中更喜欢F2,但是命运却让他和F1结婚了,显然这样的婚姻是不稳定的,随时都可 阅读详情



点击打开链接



(一)问题的引出:

有N男N女,每个人都按照他对异性的喜欢程度排名。现在需要写出一个算法安排这N个男的、N个女的结婚,要求两个人的婚姻应该是稳定的。

何为稳定?

有两对夫妻M1 F2,M2 F1。M1心目中更喜欢F1,但是他和F2结婚了,M2心目中更喜欢F2,但是命运却让他和F1结婚了,显然这样的婚姻是不稳定的,随时都可能发生M1和F1私奔或者M2和F2私奔的情况。所以在做出匹配选择的时候(也就是结婚的时候),我们需要做出稳定的选择,以防这种情况的发生。




(二)算法介绍:

参考:http://www.matrix67.com/blog/archives/2976

1962 年,美国数学家 David Gale 和 Lloyd Shapley 发明了一种寻找稳定婚姻的策略。不管男女各有多少人,不管他们各自的偏好如何,应用这种策略后总能得到一个稳定的婚姻搭配。换句话说,他们证明了稳定的婚姻搭配总是存在的。有趣的是,这种策略反映了现实生活中的很多真实情况。



算法中采用了男生主动追求女孩的形式。

算法步骤描述:


第一轮,每个男人都选择自己名单上排在首位的女人,并向她表白。这种时候会出现两种情况:(1)该女士还没有被男生追求过,则该女士接受该男生的请求。(2)若该女生已经接受过其他男生的追求,那么该女生会将该男士与她的现任男友进行比较,若更喜欢她的男友,那么拒绝这个人的追求,否则,抛弃其男友(囧)……


第一轮结束后,有些男人已经有女朋友了,有些男人仍然是单身。

在第二轮追女行动中,每个单身男都从所有还没拒绝过他的女孩中选出自己最中意的那一个,并向她表白,不管她现在是否是单身。这种时候还是会遇到上面所说的两种情况,还是同样的解决方案。直到所有人都不在是单身。




怎么证明这个算法肯定能够得到稳定的婚姻:

(1)随着轮数的增加,总有一个时候所有人都能配上对。因为男生根据自己心目中的排名依次对女士进行表白,假如有一个人没有配上对,那么这个人必定是向所有的女孩进行表白了。但是女孩只要被表白过一次,就不可能是单身,也就是说此时所有的女生都不是单身的,这与有一个人没有配上对是相悖的。所以假设不成立。该算法一定会使得所有人都能够配对成功。

(2)随着轮数的增加,男士追求的对象越来越糟,而女士的男友则可能变得越来越好。假设男A和女1各有各自的对象,但是比起现在的对象,男A更喜欢女1,所以,在此之前男A肯定已经跟女1表白过的,并且女1拒绝了男A或者甩了男A,也就是女1有了比男A更好的男友,不会出现私奔的情况……。


在这道题目里面,只不过是把人换成了信号的发射站和接收站。并且,人的好感度变成了信号发射站和接收站的距离和容量的综合考量。首先有一个问题,这道题中,把发射站看成男性还是把接收站看成男性,有关系吗?答案是没有关系,因为在设计算法的时候,男追女这样一个模式只是人为定义的,为的是得到最后的结果,一个稳定匹配。事实上如果是女追男也没有什么问题。所以无论是把发射站看成男性还是把接收站看成男性,都可以。这道题中,我把发射站看作是男性。


getdist计算距离时不用开方了,因为反正只要比较大小。注意cmp数组的写法,以及sort是左闭右开。




#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define eps 1e-8
#define MAXN 205
using namespace std;
struct temp{
int pos;
int c;
double dist;
}Rank[MAXN];
struct point{
int v;
double x;
double y;
double z;
}s[MAXN], e[MAXN];
int ranks[MAXN][MAXN], ranke[MAXN][MAXN], man[MAXN], woman[MAXN], tempman[MAXN];
int womanpos, flag, T, a, b, n;
double d, f, g;
double getdist(point A, point B)
{
    return (A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y) + (A.z - B.z) * (A.z - B.z);
}
bool cmp(temp a, temp b)
{
    if (fabs(a.dist - b.dist) < eps)
        return a.c > b.c;
        else return a.dist < b.dist;
}
void sortrank()
{
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            Rank[j].pos = j;
            Rank[j].c = e[j].v;
            Rank[j].dist = getdist(s[i], e[j]);
        }
        sort(Rank+1, Rank+n+1, cmp);
        for (int j = 1; j <= n; j++)
            ranks[i][j] = Rank[j].pos;//编号为i的男性第j喜欢的是编号为ranks[i][j]的女性
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            Rank[j].pos = j;
            Rank[j].c = s[j].v;
            Rank[j].dist = getdist(e[i], s[j]);
        }
        sort(Rank+1, Rank+n+1, cmp);
        for (int j = 1; j <= n; j++)
            ranke[i][Rank[j].pos] = j;//对于编号为i的女性编号为j的男性是第ranke[i][j]位喜欢的
    }
}
void GS()
{
    memset(man, 0, sizeof(man));
    memset(woman, 0, sizeof(woman));
    for (int i = 1; i <= n; i++) tempman[i] = 1;//tempman[i]表示编号为i的男性接下来要追求的女性的编号
    flag = 1;
    while (flag)
    {
        flag = 0;
        for (int i = 1; i <= n; i++)
            if (man[i] == 0)
        {
            flag = 1;
            womanpos = ranks[i][tempman[i]];//womanpos表示当前的男性所追求的女性的编号
            if (woman[womanpos] == 0)
            {
                woman[womanpos] = i;//woman[i]表示编号为i的女性当前男友的编号,如果还没有男友,那么值为0
                man[i] = womanpos;//man[i]表示编号为i的男性当前女友的编号,如果还没有女友,那么值为0
                tempman[i]++;
            }
            else
            {
                if (ranke[womanpos][i] < ranke[womanpos][woman[womanpos]])
                {
                    man[woman[womanpos]] = 0;
                    woman[womanpos] = i;
                    man[i] = womanpos;
                    tempman[i]++;
                }
                else
                    tempman[i]++;
            }
        }
    }
}
int main()
{
    scanf("%d", &T);
    while (T--)
    {
        scanf("%d", &n);
        for (int i = 1; i <= n; i++)
        {
            scanf("%d%d%lf%lf%lf", &a, &b, &d, &f, &g);
            s[a].v = b;
            s[a].x = d;
            s[a].y = f;
            s[a].z = g;
        }
        for (int i = 1; i <= n; i++)
        {
            scanf("%d%d%lf%lf%Lf", &a, &b, &d, &f, &g);
            e[a].v = b;
            e[a].x = d;
            e[a].y = f;
            e[a].z = g;
        }
        sortrank();
        GS();
        for (int i = 1; i <= n; i++)
            printf("%d %d\n", woman[i], i);
        printf("\n");
    }
    return 0;
}




稳定匹配算法实验 稳定匹配算法实验 包含经典题目及算法伪代码 详情参见我的博客 立即下载

相关推荐

GS稳定匹配算法实现代码

设计输入男人和女人的优先表并转化,通过自由男人的列表不断更新,最终确定出稳定匹配的对数并输出之。

稳定婚姻匹配(Stable Match, HDOJ 1435, HDOJ 1914, 详解)

稳定婚姻匹配 Stable Match Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1236 Accepted Submission(s): 583 Special Judge Problem Description Netwo...

UniverseofHK的博客 1160

LiveGBS流媒体平台GB/T28181实战指南:海康NVR物联网卡摄像头注册失败全链路排查与抓包技巧

本文详细解析了LiveGBS流媒体平台中海康NVR物联网卡摄像头注册失败的常见问题及解决方案。通过全链路排查与抓包技巧,包括物联网卡配置、多网卡冲突处理、防火墙设置等,帮助用户快速定位并解决GB/T28181协议下的设备注册难题,提升流媒体平台部署效率。

weixin_29290947的博客 502

稳定婚姻问题和Gale-Shapley算法

稳定婚姻问题和Gale-Shapley算法 作者: baiyuzhong分类:架构实践  阅读:5,662 次添加评论 文 / 顾森 什么是算法?每当有人问作者这样的问题时,他总会引用这个例子:假如你是一个媒人,有若干个单身男子登门求助,还有同样多的单身女子也前来征婚。如果你已经知道这些女孩儿在每个男孩儿心目中的排名,以及男孩儿们在每个女孩儿心中的排名,你应该怎样为他们牵线配对呢? 最

baisung的专栏 8408

判断两个多边形是否相交(java实现)

判断两个多边形是否相交 ,当前认为一个点相交也是相交,可针对凹多边形和凸边型等多复杂的多边形进行相交判断,采用java实现,因为网上java实现的比较少,所以这里写下如何实现,适用于碰撞检测,地图等等应用场景

IT_CREATE的博客 5849

Mac和VScode配置fortran

macOS系统 vscode fortran gfortran 终端

weixin_43047707的博客 2424

HDOJ 1435 Stable Match

Stable Match TimeLimit: 2000/1000 MS (Java/Others)    Memory Limit:65536/32768 K (Java/Others) Total Submission(s): 744    Accepted Submission(s): 354 Special Judge Problem Description Network公司的

Dust_heart的博客 402

训练救星!EMA多尺度注意力让YOLOv11轻松攻克自定义数据集不涨点难题

在目标检测模型训练中,自定义数据集不涨点是阻碍算法落地的核心痛点之一。传统训练策略在数据分布特殊、样本量有限的场景下极易陷入收敛停滞,而 EMA(指数移动平均)结合多尺度注意力的方案,在自定义数据集上实现mAP 提升 6.5%,同时让训练曲线从“平缓停滞”转为“持续攀升”,彻底解决创新点在自有数据上的性能瓶颈。本教程将带你从原理到实践,通过 EMA 多尺度注意力为 YOLOv11 注入训练稳定性,让你的自定义数据集模型训练实现质的飞跃。EMA 衰减率:小样本数据集建议将decay。

FJN110的博客 167

hdu1435 稳定婚姻问题

题意:                Stable Match Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 307 Accepted Submission(s): 120 Special Judge Problem

天使也掉毛 1278

直方图均衡化原理及matlab和opencv实现代码

详细分析了直方图均衡化的数学原理,配有matlab和opencv实现代码

qq_21603315的博客 4784

5、AIX系统硬件管理与故障诊断全解析

本文全面解析了AIX系统的硬件管理与故障诊断方法,涵盖系统管理服务(SMS)的使用、设备兼容性配置、设备配置数据库结构、常用命令如cfgmgr、lsattr、smitty devices的操作详解,并深入介绍了错误日志管理机制,包括errdemon、errpt、errlogger等命令的应用。通过实际案例分析和流程图展示,帮助系统管理员掌握从问题怀疑到诊断执行再到日志清理的完整流程,同时提供注意事项与最佳实践,助力AIX系统的稳定运行与高效维护。

y2z3a4b5c的博客 71

稳定匹配问题Stable Match Problem -- 稳定婚姻问题 Stable Marriage Problem

稳定匹配问题Stable Match Problem 转自:http://hi.baidu.com/revinfly/item/e48b6fbab5145bf662388e95 问题的提出         《算法》的第一堂课讲了关于稳定匹配(Stable Matching)的问题,这是一个由现实情况引出的一个很有趣的问题。假设说现有一堆学生准备到一堆公司实习,每个学生心目中对这些公司都有一个

jiyanfeng1的专栏 1万+

计算机实战分享3:森林火灾预测分析可视化机器学习预测-完整数据代码-可直接运行

计算机实战分享3:森林火灾预测分析可视化机器学习预测-完整数据代码-可直接运行

607

hdu 1435 Stable Match (稳定匹配)

Stable Match Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 811    Accepted Submission(s): 389 Special Judge Problem Description Networ

咸鱼有梦想 786

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

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

HDU 1435 Stable Match

http://acm.hdu.edu.cn/showproblem.php?pid=1435#include #include #include #include #include #include #include using namespace std; #define N

ME4546的专栏 1703

IDEA的使用指南

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

HDU 1435 Stable Match(稳定婚姻问题)

#include #include #include using namespace std; const int maxn=300+5; const double eps=1e-8; int pref[maxn][maxn],order[maxn][maxn],Next[maxn]; int future_husband[maxn],future_wife[maxn]; queue q; str

qq_33901573的博客 470

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

匹配问题

匹配问题匹配问题中的重要概念GS算法GS算法的几个特性 匹配问题中的重要概念 匹配,假设有男人的集合M和女人的集合W,每个男人向女人W求婚,并且两个人成功组成一对,就叫做匹配。 完美匹配,假设集合M和集合W的数量相同,都是n,即n个男人,n个女人,如果使用一种算法,最后所有的男人和女人成功匹配,没有一个单身的男人或者单身的女人,那么就叫做完美匹配。 不稳定匹配,假设完美匹配形成了集合S,其中男人...

HuZhenXing 5962

Stable Matching

1. What is stable matching? Definition of stable matching: perfect matching with no unstable pairs. Perfect matching: everyone is matched monogamously(一夫一妻的意思). Stability: no incentive for some pair of participants to undermine assignment by joint action.

weixin_51334343的博客 707

OSChina娱乐弹弹弹——离散数学之把妹要诀 ,你学会了吗?

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34357928的博客 349

Stable Match

稳定婚姻问题 主要就是处理两个数组 boy[i][j] 存放第i个男的第j喜欢的女的 存的是女的编号!! girl[i][j] 存放 第i个女的对第j个男的的好感度 存的是值 然后只要模板就行了 这题的数据处理有点麻烦 多学习! #include<bits/stdc++.h> using namespace std; #define N...

weixin_30318645的博客 156

经典算法问题——稳定匹配(Stable Matching)

经典算法问题——稳定匹配(Stable Matching) 问题起源 在1962年,经济学家 David Gale 和 Lloyd Shapley 提出:能否设计一个高校录取过程,能够自我执行(self-enforcing)形成一个最佳的匹配效果。 算法的 C++ 实现代码请移步 Github:https://github.com/hotelll/CS222Note/tree/master/StableMatching 简易问题 问题描述 给出一个 nnn 个男性的集合 MMM 和 nnn 个女性的集

weixin_44230421的博客 9955

matlab GS算法

输入图片为啥是三维? 第7行维度不匹配。 close all;clear all;clc; % %% simulate the complex object INput= imresize((imread('DY.JPG')),[120,90]); objectAmplitude = uint8(INput); objectPhase = uint8(imread('DY.JPG'

fangjiaoshou886的博客 9960

HDU 1435 Stable Match(稳定婚姻问题|盖尔沙普利算法)

题意: 标准的稳定匹配问题,具体的看刘汝佳的训练指南,很好理解,并不难,所以这题可以用来测板子。 代码:// // Created by CQU_CST_WuErli // Copyright (c) 2016 CQU_CST_WuErli. All rights reserved. // #include <iostream> #include <cstring> #include <c

只玩三国的程序猿的专栏 1583

稳定婚配问题-Gale-Shapley算法

1.GS算法基础 有N男N女,每个人都按照他对异性的喜欢程度排名。现在需要写出一个算法安排这N个男的、N个女的结婚,要求两个人的婚姻应该是稳定的。 何为稳定? 有两对夫妻M1 F2,M2 F1。M1心目中更喜欢F1,但是他和F2结婚了,M2心目中更喜欢F2,但是命运却让他和F1结婚了,显然这样的婚姻是不稳定的,随时都可能发生M1和F1私奔或者M2和F2私奔的情况。所以在做出匹配选择的时候(也就是结...

Ogmx的博客 2535

稳定匹配 G-S算法

问题精炼,形式化,引出G-S算法。 命题1: 被动方的状态会越来越好 命题2:主动方的状态会也来越差 定理1.3:复杂度o(n^2) 很容易理解 定理1.4:不存在主动方自由被动方同时都锁定状态 定理1.5:终止时返回集合S是完美匹配 定理1.6:G-S算法一次执行,返回集合S是稳定匹配 定理1.7:G

Ehco00x0的博客 3431
上一篇: HDOJ 4418 Time travel (bfs + 高斯消元)
下一篇: HDOJ 3585 maximum shortest distance (二分+最大团)
Muya77
博客等级 码龄11年 1粉丝 82原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址