hdu 4585 2013杭州邀请赛 Shaolin

ABB_PC_SDK开发文档 CHM格式 英文版 ABB_PC_SDK官方开发文档 CHM格式 英文版 对应SDK版本PC SDK 6.07 立即下载

Shaolin

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 0    Accepted Submission(s): 0


Problem Description
Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The master of Shaolin evaluates a young man mainly by his talent on understanding the Buddism scripture, but fighting skill is also taken into account. When a young man passes all the tests and is declared a new monk of Shaolin, there will be a fight , as a part of the welcome party. Every monk has an unique id and a unique fighting grade, which are all integers. The new monk must fight with a old monk whose fighting grade is closest to his fighting grade. If there are two old monks satisfying that condition, the new monk will take the one whose fighting grade is less than his. The master is the first monk in Shaolin, his id is 1,and his fighting grade is 1,000,000,000.He just lost the fighting records. But he still remembers who joined Shaolin earlier, who joined later. Please recover the fighting records for him.
 

Input
There are several test cases. In each test case: The first line is a integer n (0 <n <=100,000),meaning the number of monks who joined Shaolin after the master did.(The master is not included).Then n lines follow. Each line has two integer k and g, meaning a monk's id and his fighting grade.( 0<= k ,g<=5,000,000) The monks are listed by ascending order of jointing time.In other words, monks who joined Shaolin earlier come first. The input ends with n = 0.
 

Output
A fight can be described as two ids of the monks who make that fight. For each test case, output all fights by the ascending order of happening time. Each fight in a line. For each fight, print the new monk's id first ,then the old monk's id.
 

Sample Input
3 2 1 3 3 4 2 0
 

Sample Output
2 1 3 2 4 2
用了个set就过了,
#include <iostream>
#include <stdio.h>
#include <set>
#include <string.h>
using namespace std;
struct node
{
  int id,val;
  bool operator < (node b)const
  {
      if(val!=b.val)
      return val<b.val;
      return id<b.id;
  }
};
set<node> q;
set<node >::iterator p,pp;
int main()
{
    int n,id,val,i,maxid,minid,maxval,minval;
    node temp;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0)
        break;
        q.clear();
        temp.id=1;temp.val=1000000000;
        q.insert(temp);
        for(i=2;i<=n+1;i++)
        {
            scanf("%d%d",&temp.id,&temp.val);
            q.insert(temp);
            //p=q.begin();
            p=q.find(temp);
            if(p==q.begin())
            {
                p++;
                printf("%d %d\n",temp.id,p->id);
                continue;
            }

            p++;
            if(p==q.end())
            {
                p--;p--;
               printf("%d %d\n",temp.id,p->id);
               continue;
            }
            p--;
            p--;
            minval=p->val;
            minid=p->id;
            ++p,++p;
            maxval=p->val;
            maxid=p->id;
            if(maxval-temp.val<temp.val-minval)
            {
                printf("%d %d\n",temp.id,maxid);
            }
            else
                printf("%d %d\n",temp.id,minid);


        }
    }

    return 0;
}


【毕设保姆级指南】基于YOLOv8的DAGM 2007工业缺陷检测系统从搭建到落地 本教程基于YOLOv8算法实现DAGM 2007工业缺陷检测系统,包含数据处理、模型训练和可视化界面开发全流程。首先对DAGM数据集进行格式转换和划分,然后通过YOLOv8训练工业缺陷检测模型,最终构建PyQt5交互界面实现缺陷可视化检测。该系统可用于智能制造中的产品质量控制,帮助快速定位工业产品缺陷,提升检测效率和准确性,为工业质检提供高效解决方案。 阅读详情

相关推荐

戴维南和诺顿定理到底怎么选?一个实际维修案例讲透两种等效电路用法

本文通过工业电源模块维修案例,详细解析戴维南和诺顿定理在实际电路分析中的选择策略。针对电压敏感型故障、电流分配问题及功率传输异常,提供三大黄金法则,帮助工程师高效选择等效电路方法,提升故障排查效率。特别强调诺顿定理在电流分析中的优势。

weixin_31854867的博客 364

HDU 4585 Shaolin(map用法)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4585 思路:首先要知道map<key,value>是会自动对key值排序的,map实质上就是一棵红黑树(忘了在哪看过)。lower_bound()也是关于key值来查找。 #include<iostream> #include<cstring> #include...

诗鸩的博客 201

IsaacLab 从入门到精通(一) 环境配置和依赖安装

本系列文章将针对机器人操作任务中的强化学习平台IsaacLab提供较为全面的教程

DejaWu33的博客 1万+

hdu4585 shaolin【 Treap模板题】

一个模板题卡了将近一上午,忧伤 题意:少林的和尚入学,依次入学,每人有一个独一无二的id和独一无二的水平值(由于这句,可以不用修改模板),到校之后与跟他水平相近的干仗,老方丈的id=1,水平是1,000,000,000(把这个数insert你就废了==),已知入学顺序和水平值,问每个人跟谁干仗。 研究半天treap模板,值满足二叉搜索树,优先级满足大根堆,优先级可以用系统随机数然后unique

MissZhou要努力 763

Shell编程规范及变量

文章目录一.Shell脚本1.1Shell概述1.2Shell脚本 一.Shell脚本 1.1Shell概述 Shell是Linux系统中开机自动加载的一个特殊程序,它将用户输入的指令,转换成Linux内核可以识别的语言,从而让内核执行调用硬件。 Bash是Linux系统中默认使用shell的程序,它位于/bin/bash。 1.2Shell脚本 将需要执行的命令保存到一个文件中,按照顺序执行,它不需要编译,它是解释型的 ...

夏颜的博客 3696

从分立到集成:深入解析Buck电路的核心模块与设计权衡

本文深入解析Buck电路的核心模块与设计权衡,从分立到集成方案的优缺点对比。详细探讨Buck电路的高效能量转换、小型化设计及灵活电压调节能力,并结合实际案例分享分立方案中的PWM生成、反馈环路设计及保护电路优化经验,为工程师提供实用设计参考。

weixin_29306317的博客 230

Shaolin

Shaolin Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The master of Shaolin evaluates a young man mainly by his talent on understanding the Buddism scripture, but fighting

weixin_51474839的博客 269

MediaPipe+Unity动作捕捉实战:如何用普通摄像头驱动3D人物模型(附避坑指南)

本文详细介绍了如何利用MediaPipe和Unity实现低成本动作捕捉,仅需普通摄像头即可驱动3D人物模型。通过MediaPipe的3D坐标预测能力,结合Unity的骨骼映射优化,解决单目摄像头下的三维重建难题,并提供实战避坑指南和性能优化技巧,帮助开发者快速实现专业级的人物模型驱动效果。

weixin_29047545的博客 371

Shaolin HDU - 4585(map模板题)

题意: 少林寺有n+1个和尚,他们都有一个独有的编号和战斗力值,当一个年轻人通过所有考试并被宣布为少林的新僧人时,将会有一场战斗,作为欢迎的一部分。新和尚必须与一位战斗等级最接近他的战斗等级的老和尚战斗。如果有两个老僧人满足这个条件,新僧侣将采取战斗等级低于他的僧侣与他对打。现在保证输入是按照编号顺序升序输入的,要求按顺序输出每一组战斗的双方编号,先输出新和尚的后输出老和尚的。(第一个和尚编号是1...

zeng_jun_yv的博客 460

普罗米修斯监控达梦数据库集群

-----------------------------------新增文件---------------------------------------注:图上即为启动成功,如果没有问题,则使用nohup后台启动程序。官网地址:https://github.com/gy297879328/dameng_exporter。注:prometheus的对数据库的指标采集如果高于60s一次,请手动修改提供表盘中的计算值。修改dameng_exporter.config配置文件,修改账号密码的部分。

weixin_49985403的博客 1695

K8S搭建(centos)完整版

每个人都有惰性,但不断学习是好好生活的根本,共勉!

感谢阅读 4156

hdu 4585 Shaolin

Shaolin Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others) Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The master of

GitHub:https://github.com/myp020301 319

构建AI Agent驱动的智能健康管理系统

数据碎片化:健康数据分散在不同的设备和平台中,难以统一管理和分析。个性化不足:健康管理方案通常是通用的,难以根据个人的健康状况实时调整。用户参与度低:用户难以获得及时、个性化的健康建议,导致健康管理效果不佳。AI Agent是一个能够感知环境、采取行动以实现目标的智能实体。根据智能体的智能水平,可以分为简单反应式智能体和复杂适应式智能体。实时监测健康数据。获取个性化的健康建议。收到健康风险预警。

AI天才研究院 757

HDU 4585 Shaolin 2013杭州邀请赛

题意无坑,不再赘述 这里题目暴力会超时,所以用STL,时间是O(nlogn),所以跑起来还是比较理想的 下面附几组数据 //171MS 3404K 732B C++ #include #include using namespace std; struct node{ int id,fi; node(){} node(int i ,int f):id(i),fi(f){}

九野的博客 1674

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

深度学习工具包 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 4585 Shaolin(2013杭州邀请赛J题-二分)

http://acm.hdu.edu.cn/showproblem.php?pid=4585 题意:少林一些和尚,每个和尚有一个id和一个分值,按输入顺序一个个和尚进来,一开始寺庙有一个住持,分数无限大,编号为1,然后每个和尚进来后会找寺庙已经有的和尚PK,尽量找分接近的,如果有两个接近的,就找分小的那个,注意和尚ID和分数都不会重复,求出这个PK顺序。 思路:这题用set非常方便,和尚进

Remilia's 1319

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

hdu 4585 Shaolin 2013 ACM-ICPC杭州赛区全国邀请赛——题目重现

实际上要做题目就是要进行快速的查找和插入,这个功能可以用set来实现 所代码就很好写了 /********* PRO: hdu 4585 TIT: Shaolin DAT: 2013-08-10-12.28 AUT: UKean EMA: huyocan@163.com *********/ #include #include #include #define INF 1e18 using n

柯安的专栏 1726

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

HDU 4585 Shaolin

Shaolin Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of young men go to Shaolin temple every year, trying to be a monk there. The master of Shaolin evaluates a young ...

weixin_34284188的博客 115

HDU 4585 Shaolin (STL)

Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 315    Accepted Submission(s): 162 Problem Description Shaolin temple is very famous ...

weixin_34161064的博客 182

hdu4585 shaolin Treap

Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 1945    Accepted Submission(s): 836 Problem Description Shaolin temple is very

Magle 954

8#10 - 杭州邀请赛 重现

01 - Robot  02 - X-Boxes 03 - Transformation 04 - Random Walk 07 - DFS spanning tree 09 - Building bridges 10 - Shaolin Hard 05 -  06 -  08 -  传送门: Solved Pro.ID Ti

XDU_Truth的专栏 1355

hdu 4585 Shaolin

Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 1178    Accepted Submission(s): 501 Problem Description Shaolin temple is very famo

云华100的专栏 461

hdu 4585 Shaolin两种方法(暴力和STL map set)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4585 Problem Description Shaolin temple is very famous for its Kongfu monks.A lot of yo...

adr5970的博客 157

hdu 4585 Shaolin (Treap)

Shaolin Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Total Submission(s): 3340    Accepted Submission(s): 1423 Problem Description Shaolin temple is very

Timeclimber 523
上一篇: hdu 4485 2013杭州邀请赛 Building bridges
下一篇: hdu4576 Robot
相知无悔
博客等级 码龄14年 65粉丝 467原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值