学校招收学生   优先级按照:  分数  是否本地  志愿先后

相当于 女的开后宫

对gs进行略微修改

结束的条件为每个男的表白完所有女的

第二部分比较时    找出女的后宫里的吸引力最弱的男的比较  然后是否取代

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 200
#define eps 1e-6
using namespace std;
struct node
{
int id,region,score,k;
}stu[N];
struct node1
{
int region,num;
}sch[N];
struct node2
{
int cnt;
int manname[N];
}woman[N];
int r,n,m;
int map1[N][N],map2[N][N],man[N],times[N],vis[N];
int cmp(node a,node b)
{
if(a.region==r)
{
if(b.region==r)
return a.score>b.score;
if(b.region!=r)
{
if(abs(a.score-0.7*b.score)<eps)
return ;
else
return a.score>0.7*b.score;
}
}
else if(b.region==r)
{
if(a.region==r)
return a.score>b.score;
if(a.region!=r)
{
if(abs(b.score-0.7*a.score)<eps)
return ;
else
return b.score<0.7*a.score;
}
}
else
return a.score>b.score;
}
int cmp1(node a,node b)
{
return a.id<b.id;
}
void makerank()
{
int i,j;
for(i=;i<=m;i++)
{
r=sch[i].region;
sort(stu+,stu+n+,cmp);
for(j=;j<=n;j++)
map2[i][stu[j].id]=j;
}
sort(stu+,stu+n+,cmp1);
}
void Gale_Shapley()
{
int flag=,i,j,worstrank,worstrankj;
memset(man,,sizeof(man));
for(i=;i<=n;i++)
times[i]=;
for(i=;i<=n;i++)
vis[i]=;
for(i=;i<=m;i++)
woman[i].cnt=;
while(flag)
{
flag=;
for(i=;i<=n;i++)
{
while(!man[i]&&!vis[i])
{
flag=;
if(times[i]>stu[i].k)
{
vis[i]=;
break;
}
int name=map1[i][times[i]];
if(woman[name].cnt<sch[name].num)
{
woman[name].manname[++woman[name].cnt]=i;
man[i]=name;
times[i]++;
}
else if(woman[name].cnt==sch[name].num)
{
worstrank=;
for(j=;j<=woman[name].cnt;j++)
{
if(map2[name][woman[name].manname[j]]>worstrank)
{
worstrank=map2[name][woman[name].manname[j]];
worstrankj=j;
}
}
if(map2[name][i]<worstrank)
{
man[woman[name].manname[worstrankj]]=;
woman[name].manname[worstrankj]=i;
man[i]=name;
times[i]++;
}
else
times[i]++;
}
}
}
}
}
int main()
{
int T,j,i;
scanf("%d",&T);
while(T--)
{
memset(map1,,sizeof(map1));
memset(map2,,sizeof(map2));
scanf("%d%d",&n,&m);
for(i=;i<=n;i++)
{
stu[i].id=i;
scanf("%d%d%d",&stu[i].region,&stu[i].score,&stu[i].k);
for(j=;j<=stu[i].k;j++)
{
scanf("%d",&map1[i][j]);
}
}
for(i=;i<=m;i++)
{
scanf("%d%d",&sch[i].region,&sch[i].num);
}
makerank();
Gale_Shapley();
for(i=;i<=n;i++)
if(vis[i])
printf("not accepted\n");
else
printf("%d\n",man[i]);
if(T) printf("\n");
}
return ;
}

University Entrace Examination zoj1023的更多相关文章

  1. POJ题目细究

    acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  102 ...

  2. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  3. POJ题目排序的Java程序

    POJ 排序的思想就是根据选取范围的题目的totalSubmittedNumber和totalAcceptedNumber计算一个avgAcceptRate. 每一道题都有一个value,value ...

  4. HDU 4442 Physical Examination

    Physical Examination Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64 ...

  5. HDU 4442 Physical Examination(贪心)

    HDU 4442 Physical Examination(贪心) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=4442 Descripti ...

  6. hdu 4442 Physical Examination 贪心排序

    Physical Examination Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...

  7. CSUOJ 1603 Scheduling the final examination

    1603: Scheduling the final examination Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 49  Solved: 1 ...

  8. 2017 New Year’s Greetings from Sun Yat-sen University

    As winter turns to spring, the world around us begins to take on an air of freshness. As  2017 is fa ...

  9. Divide and conquer:Moo University - Financial Aid(POJ 2010)

    Moo University - Financial Aid 其实是老题了http://www.cnblogs.com/Philip-Tell-Truth/p/4926008.html 这一次我们换二 ...

随机推荐

  1. 【题解】 bzoj2748 [HAOI2012]音量调节 (动态规划)

    懒得复制,戳我戳我 Solution: 傻逼题目,直接dp就可以了,他是求最后一次的最大值 Code: //It is coded by Ning_Mew on 4.17 #include<bi ...

  2. 杭高OI20190125 (genies出题)

    /* 当一个人先从自己的内心开始奋斗,他就开始迈向了成功 ——genies (朝阳的二愣子) */ HGOI寒假赛第一场,欢迎来自各种学校的各式各样的巨老233333 感觉自己好渺小.还是NOIP ( ...

  3. jq给单选框 radio添加或删除选中状态

    $("#div1 :radio").removeAttr("checked");//删除目标div下所有单选框的选中状态 $("#div1 :radi ...

  4. Centos 搭建 http服务器

    1,安装 yum install httpd 2,查看是否安装成功 netstat [root@localhost ~]# netstat -anp | grep 80      tcp 0 0 :: ...

  5. python的面向对象-类的数据属性和实例的数据属性相结合-无命名看你懵逼不懵逼系列

    1. class Chinese: country='China' def __init__(self,name): self.name=name def play_ball(self,ball): ...

  6. vue+webpack开发(一)

    一开始接触这个vue+webpack的时候,实在是摸不着头脑,根本无从下手. 但是经过这两天的研究,其实你会发现vue其实并不难,难度都在webpack你对webpack的理解. webpack顾名思 ...

  7. 20181105 Timer(慕课网)

    定时任务调度 基于给定的时间点,给定的时间间隔或者给定的执行次数自动执行的任务 Java中的定时调度工具 Timer JDK提供,不许引入 功能简单,能用Timer尽量用 Quartz 需要引入 功能 ...

  8. angular.module()参数问题

    var app = angular.module('myApp', []); 第二个参数是依赖的模块,因为这里不需要依赖其它模块,因此为空,但是[]不能省略.

  9. argunlar 1.0.0 【hello,world】

    <!DOCTYPE html><html lang="en" ng-app><head>    <meta charset="U ...

  10. CString 与其它数据类型转换问题

    CString 头文件#include <afx.h> string 头文件#include <string.h> CString 转char * CString cstr; ...