#pragma warning (disable:4786)
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
using namespace std;
int n,m;
int B[100005];
int flag;
int cnt;//第几轮次被淘汰
int group[1005],num_in_group;
struct mice
{
int id;
int weight;
bool join;
int rounds;
int rank;
};
mice TT[100005];
bool judge()
{
for(int i=0;i<n;i++)
{
if(TT[i].join==false) return true;
}
return false;
}
bool cmp(mice a,mice b)
{
return a.rounds >b.rounds;
}
bool cmp1(mice a,mice b)
{
return a.id<b.id;
}
void process(int num)
{
if(flag==n-1)
{
TT[group[0]].rounds=cnt;
TT[group[0]].join=true;
return;
}
int _id=-1,_max=-1,i;
for(i=0;i<num;i++)
{
if(TT[group[i]].weight>_max)
{
_max=TT[group[i]].weight;
_id=i;
}
}
for(i=0;i<num;i++)
{
if(i==_id) continue;
TT[group[i]].rounds=cnt;
TT[group[i]].join=true;
flag++;
}
}
int main()
{
while(scanf("%d%d",&n,&m)!=EOF)
{
int i,j;
//-------input--------
for(i=0;i<n;i++)
{
scanf("%d",&TT[i].weight);
TT[i].join=false;
TT[i].id=i;
}
for(i=0;i<n;i++) scanf("%d",&B[i]);
//------group----------
cnt=1;
flag=0;
while(judge())
{
num_in_group=0;
for(i=0;i<n;i++)
{
if(TT[B[i]].join==true) continue;
group[num_in_group++]=B[i];
if(num_in_group==m)
{
process(num_in_group);
num_in_group=0;
}
}
if(num_in_group) process(num_in_group);
cnt++;
}
//-------output----------
sort(TT,TT+n,cmp);
TT[0].rank=1;
for(i=1;i<n;i++)
{
if(TT[i].rounds==TT[i-1].rounds)
TT[i].rank=TT[i-1].rank;
else TT[i].rank=i+1;
}
sort(TT,TT+n,cmp1);
for(i=0;i<n;i++)
{
if(i!=n-1)
printf("%d ",TT[i].rank);
else
printf("%d\n",TT[i].rank);
}
}
return 0;
}相关推荐
国央企创新负责人如何通过平台实现科研成果的快速识别与转化?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
PAT1056.Mice and Rice (25)
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1056 这题为浙大2013年考研复试上机的倒数第二题,分值为25分。此题得分率很低。 在考试之后,很多考生反映,题目读不懂。 读不懂应该是源于sample input中的第三行。第三行的序列给出的是依次要进行比较的老鼠的编号。 Sample Input: 11 3 25 18 0 4
PotPlayer自用皮肤
自用 PotPlayer 皮肤,仅微调了字体大小与颜色,是按个人习惯调整,未做适配性调整。
ZJU-PAT 1010. Radix (25)
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is "yes", if 6 is a decimal number and 110 is a binary number. Now for any pair of positive
2-shell及常用命令-续.pdf
2-shell及常用命令-续.pdf
inferCNV包安装问题及解决办法
InferCNV是一个由broad研究所开发的,利用单细胞转录组数据分析肿瘤细胞拷贝数变异(CNV)的工具。基本思路是在整个基因组范围内,通过计算肿瘤细胞关于参考的“正常”细胞的相对表达,利用滑窗思想对邻近的基因相对表达,计算拷贝数。 先贴一个官方安装说明: 官方infercnv安装说明 安装infercnv包: if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") BiocManager:
ZJU-PAT 1065. A+B and C (64bit) (20)
Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C. Input Specification: The first line of the input gives the positive number of test cases, T ( Output
均值场博弈_平均场博弈(mean field game)
The New Big Fish Called Mean-Field Game Theory原文链接http://www.science4all.org/article/mean-field-games/www.science4all.org主要内容在经典博弈论中,它对附近其他鱼类的行为做出反应。这是非常复杂的,因为不同的鱼类之间会有大量的相互作用。这意味着经典博弈论对应于一长串高度耦合的方程。...
ZJU-PAT 1080. Graduate Admission (30) 浙大2014年上机复试第四题
#include #include #include #include using namespace std; const int maxn=40005; const int maxm=101; int n,m,k; int num[maxm]; int lastRank[maxm]; vector mm[maxm]; struct stu { int id; int G
Simulink玩转PMSM无感FOC:从IF强拖参数调试到切换失败的避坑指南
本文深入探讨了Simulink在PMSM无感FOC控制中的IF强拖启动参数调试与切换避坑技巧。通过详细解析强拖加速、速度维持和闭环切换三大阶段的设计逻辑,以及五个常见陷阱的解决方案,帮助工程师快速定位启动失败和切换震荡问题。文章还提供了典型故障的波形诊断方法和高级调试工具链优化建议,是电机控制领域的实用指南。
Notion卡顿救星:3分钟搞定DNS优化,手机电脑全平台加速指南
本文针对Notion访问慢和卡顿问题,提供了全平台DNS优化与Hosts文件修改的详细指南。通过更换优质DNS服务器或建立静态IP映射,可有效解决因网络延迟和域名解析导致的加载缓慢,实现手机与电脑端的快速加速,提升Notion使用流畅度。
ZJU-PAT 1079. Total Sales of Supply Chain (25) 浙大2014年上机复试第三题
#include #include using namespace std; struct Node { int parent; //父节点 bool flag; //是否是retailers int level; //第几层 int num; //销售多少个 }; Node tt[100005]; int n; double p,r,sum;
从ROS2到ROS1:Lightning-LM激光SLAM模块的移植实践与核心代码解析
本文详细解析了将高性能激光SLAM算法Lightning-LM从ROS2移植到ROS1的完整实践过程。针对ROS1与ROS2在节点初始化、话题通信、参数服务器及TF发布等核心API的差异,文章提供了loc_system和slam模块的核心代码改造示例,并给出了适配catkin的CMakeLists.txt与package.xml配置方案,帮助开发者在现有ROS1生态中高效集成先进的SLAM模块。
ZJU-PAT 1057. Stack (30) 浙大2013年上机复试第三题
#pragma warning (disable:4786) #include #include #include #include #include using namespace std; int n,d;; int A[10005],B[10005]; int select(int num) { for(int i=1;i<=d;i++) B[i]=A[i];
【企业智能体开发】优化模型成本、延迟与失败降级
小林的培训快开始时,服务台花很久“思考最优回答”,体验并不会更好。反过来,为了省钱而始终选最轻的模型,若连房间、连接方式和任务状态都识别不稳,后续错误检索和重复建单会造成更大代价。企业 Agent 的优化对象不是单次模型调用价格,而是任务在可接受时间内、安全地推进到正确结果的总成本。
手把手教你学PCIE(11.3)--pcie的认证和合规性测试
PCIe 设备的认证和合规性测试是确保设备正常工作和达到预期性能的关键步骤。通过使用 PCI-SIG 提供的测试工具和第三方测试工具,可以全面评估 PCIe 设备的物理层、链路层、事务层和互操作性,确保设备符合行业标准和规范。
ZJU-PAT 1070. Mooncake (25)
Mooncake is a Chinese bakery product traditionally eaten during the Mid-Autumn Festival. Many types of fillings and crusts can be found in traditional mooncakes according to the region's culture. Now
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
ZJU-PAT 1081. Rational Sum (20)
模拟题 #pragma warning (disable:4786) #include #include #include #include #include #include #include using namespace std; long long int sum,ans,sum1; int n; struct Node { long long int numerato
LinePhone3.2.7(android端最新版本) sip客户端
SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/
数学建模模型总结
这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!
ZJU-PAT 1054. The Dominant Color (20) 浙大2013年上机复试第一题
#pragma warning (disable:4786) #include #include #include #include using namespace std; int main() { int m,n; while(scanf("%d%d",&m,&n)!=EOF) { int i,j; string s; map ans;
win10 跳过U8环境检测的IE WebControls.rar
win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。
ZJU-PAT 1077. Kuchiguse (20) 浙大2014年上机复试第一题
#include #include #include #include using namespace std; string longest_common_suffix(string a,string b) { string tmp=""; int len1=a.size()-1; int len2=b.size()-1; while(len1>=0 && len2>=0) {
ZJU-PAT 1055. The World's Richest (25) 浙大2013年上机复试第二题
#pragma warning (disable:4786) #include #include #include #include #include using namespace std; int m,n; int num,Min,Max; struct people { string name; int age,money; }; people TT[
ZJU PAT 1012 The Best Rank
#include #include #include #include using namespace std; #define Min(a,b)(a<b?a:b) int n,m; struct student { int id,ctest,math,english; double avg; int crank,mrank,erank,arank; int bestrank; st
ZJU-PAT 1050
#include #include using namespace std; /* Sample Input: They are students. aeiou Sample Output: Thy r stdnts. */ bool myhash[150]; string s1,s2; void run() { getline(cin,s2); int i; string
ZJU-PAT 1051 Pop Sequence
#include #include #include using namespace std; int m,n,cases; stack f; int a[1005]; bool Judge() { while(f.empty()==false) f.pop(); int i,j; for(i=0;i<n;i++) scanf("%d",&a[i]); if(a[0]>m) re
1793



被折叠的 条评论
为什么被折叠?



