【PAT甲级】1080 Graduate Admission (30 分)
题意:
输入三个正整数N,M,K(N<=40000,M<=100,K<=5)分别表示学生人数,可供报考学校总数,学生可填志愿总数。接着输入一行M个正整数表示从0到M-1每所学校招生人数,N行数据分别包括两个成绩和K个志愿。输出M行依照平行志愿原则输出每所学校录取的学生序号,如果成绩相同,可以突破计划招生人数。
trick:
不是很懂为什么当我输出的时候采用if(i>0)cout<<"\n";会导致测试点2和4格式错误。。。。。
发现最后一行必须要换行。。。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
typedef struct student{
int x,y;
int id;
int c[];
};
student d[];
int a[];
int b[];
vector<int>ans[];
bool cmp(student a,student b){
if(a.x+a.y!=b.x+b.y)
return a.x+a.y>b.x+b.y;
return a.x>b.x;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,m,k;
cin>>n>>m>>k;
for(int i=;i<m;++i)
cin>>a[i];
for(int i=;i<n;++i){
cin>>d[i].x>>d[i].y;
for(int j=;j<=k;++j)
cin>>d[i].c[j];
d[i].id=i;
}
sort(d,d+n,cmp);
int tamp=-;
for(int i=;i<n;++i){
if(i>&&d[i].x+d[i].y<d[i-].x+d[i-].y)
tamp=-;
for(int j=;j<=k;++j){
if(a[d[i].c[j]]){
--a[d[i].c[j]];
ans[d[i].c[j]].push_back(d[i].id);
tamp=d[i].c[j];
break;
}
else if(d[i].c[j]==tamp&&d[i].y==d[i-].y&&d[i].x==d[i-].x){
ans[tamp].push_back(d[i].id);
break;
}
}
}
for(int i=;i<m;++i)
sort(ans[i].begin(),ans[i].end());
for(int j=;j<ans[].size();++j){
if(j>)
cout<<" ";
cout<<ans[][j];
}
for(int i=;i<m;++i){
cout<<"\n";
for(int j=;j<ans[i].size();++j){
if(j>)
cout<<" ";
cout<<ans[i][j];
}
}
cout<<endl;
return ;
}
【PAT甲级】1080 Graduate Admission (30 分)的更多相关文章
- PAT 甲级 1080 Graduate Admission (30 分) (简单,结构体排序模拟)
1080 Graduate Admission (30 分) It is said that in 2011, there are about 100 graduate schools ready ...
- pat 甲级 1080. Graduate Admission (30)
1080. Graduate Admission (30) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue It ...
- PAT甲级1080 Graduate Admission【模拟】
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805387268571136 题意: 模拟高考志愿录取. 考生根据总 ...
- PAT 甲级 1072 Gas Station (30 分)(dijstra)
1072 Gas Station (30 分) A gas station has to be built at such a location that the minimum distance ...
- PAT 甲级 1049 Counting Ones (30 分)(找规律,较难,想到了一点但没有深入考虑嫌麻烦)***
1049 Counting Ones (30 分) The task is simple: given any positive integer N, you are supposed to co ...
- PAT 甲级 1030 Travel Plan (30 分)(dijstra,较简单,但要注意是从0到n-1)
1030 Travel Plan (30 分) A traveler's map gives the distances between cities along the highways, to ...
- PAT 甲级 1026 Table Tennis (30 分)(坑点很多,逻辑较复杂,做了1天)
1026 Table Tennis (30 分) A table tennis club has N tables available to the public. The tables are ...
- PAT 甲级 1022 Digital Library (30 分)(字符串读入getline,istringstream,测试点2时间坑点)
1022 Digital Library (30 分) A Digital Library contains millions of books, stored according to thei ...
- PAT 1080. Graduate Admission (30)
It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...
随机推荐
- [CF1236D] Alice and the Doll - 模拟,STL
[CF1236D] Alice and the Doll Description \(N \times M\)网格,有 \(K\) 个格子里有障碍物.每次经过一个格子的时候只能直走或者右转一次.初态在 ...
- ASPxDashboardViewer_OnDashboardLoaded 修改Item参数
protected void ASPxDashboardViewer_OnDashboardLoaded(object sender, DashboardLoadedWebEventArgs e) { ...
- normalization, standardization and regularization
Normalization Normalization refers to rescaling real valued numeric attributes into the range 0 and ...
- python logging模块日志回滚RotatingFileHandler
# coding=utf-8 import logging import time import os import logging.handlers def logger(appname,roots ...
- 图像滤波—opencv函数
函数原型 方框滤波 ,-), bool normalize = true, int borderType = BORDER_DEFAULT) 均值滤波 ,-), int borderType = ...
- fpga vga 显示
VGA(Video Graphics Array)是IBM在1987年随PS/2机一起推出的一种视频传输标准,具有分辨率高.显示速率快.颜色丰富等优点,在彩色显示器领域得到了广泛的应用.不支持热插拔, ...
- 实体的时间date属性的字段之表单提交
@InitBinder public void initBinder(WebDataBinder binder) { DateFormat dateFormat = new SimpleDateFor ...
- php中文乱码问题的终极解决方案汇总
乱码是我们在开发可能经常遇见,也是最让人头疼的一个问题了,下面这篇文章主要介绍了在php开发中,可能遇见中文乱码问题的终极解决方案,文中介绍好几个情况下的解决方法,需要的朋友可以参考借鉴,下面来一起看 ...
- 题解【洛谷P3884】[JLOI2009]二叉树问题
题面 题解 这道题目可以用很多方法解决,这里我使用的是树链剖分. 关于树链剖分,可以看一下我的树链剖分学习笔记. 大致思路是这样的: 第\(1\)次\(dfs\)记录出每个点的父亲.重儿子.深度.子树 ...
- Android开发实战——记账本(5)
开发日志——(5) 今天打算将图标的功能实现,将打开图表的选项放在右上方,所以重写MainActivity中的onOptionsItemSelected方法.增添Chart选项 public ...