HDU 1050 Moving Tables

数字IC后端PR阶段Innovus,ICC,ICC2修复short万能脚本分享 阅读详情

WA到不省人事。。。贪心,求不相交区间。

#include<iostream>
#include<string>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<algorithm>

using namespace std;

const int maxn = 210;

struct Seg{
    int a,b;
}s[maxn];

int n,cnt;
bool vis[maxn];

void swap(int &a,int &b){
    if(a>b){int tmp=a;a=b;b=tmp;}
}

void solve(){
    int i,j;
    for(i=0;i<n;i++)
        if(!vis[i]) break;
    if(i==n) return;
    cnt++;
    vis[i]=true;
    for(j=i++;i<n;i++)
        if(!vis[i])
            if(s[i].a>s[j].b){
                j=i;
                vis[j]=true;
            }
    solve();
}

bool cmp(const Seg s1,const Seg s2){
    return s1.a<s2.a;     //按起点排序,一开始是按终点排序的。。。因为最左边的点是必须取的,所以作为第一个取的点。。我看白书后思维僵化了。。很多东西要灵活应用啊,这题不仅仅是求不相交区间最大数目- -!在含有其他条件的情况下要灵活应变
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("a.in", "r", stdin);
#endif
    int t;
    cin>>t;
    while(t--){
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>s[i].a>>s[i].b;
            s[i].a=(s[i].a+1)/2;     //这里没想到可以这样处理,看discuss看到的,我果然弱爆了 
            s[i].b=(s[i].b+1)/2;
            swap(s[i].a,s[i].b);
        }
        memset(vis,false,sizeof(vis));
        sort(s,s+n,cmp);
        cnt=0;
        solve();
        cout<<cnt*10<<endl;
    }
    return 0;
}


基于OpenCV C++实现工业级形状模板匹配:仿Halcon SBM算法全解析 在计算机视觉和工业自动化领域,模板匹配是一项基础且关键的技术,用于在图像中定位已知目标。其核心原理是通过计算图像区域与预设模板之间的相似度来识别目标位置。传统的基于灰度值的匹配方法对光照变化敏感,鲁棒性不足。而基于边缘梯度方向的形状匹配技术,通过计算轮廓梯度方向的一致性进行相似度度量,从根本上提升了对光照变化的鲁棒性,并支持目标的旋转与缩放,技术价值显著。这项技术广泛应用于工业视觉检测、机器人引导、PCB定位等对精度和稳定性要求极高的场景。本文聚焦于使用开源OpenCV库,从底层仿照Halcon的Shape 阅读详情

相关推荐

电源完整性必看!用SIwave提取PDN阻抗曲线的3个关键设置与常见报错解决

本文深入探讨了在SIwave中进行电源完整性(PI)仿真时,提取PDN阻抗曲线的三个核心设置要点。重点解析了端口阻抗设为0.1欧姆的物理意义与SYZ参数仿真中的阻抗匹配原则,并提供了针对常见收敛性问题和模型误差的实战排查思路,旨在帮助工程师获得更精确可靠的仿真结果,为去耦电容优化提供依据。

b9c0d的博客 352

hdu-1050 Moving Tables

hdu-1050 Moving Tables 题目链接 Problem description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms...

bayleexu 350

海思SD3403/SS928开发(二)环境搭建:从零到一构建高效开发环境的实战指南

本文详细介绍了海思SD3403/SS928开发板环境搭建的全流程,包括Ubuntu系统选择、基础配置、开发环境依赖安装、SDK工具链配置等关键步骤。通过实战经验分享,帮助开发者避免常见问题,快速构建高效开发环境,提升开发效率。

weixin_28717683的博客 284

HDU-1050-Moving Tables(C++ && 贪心初步)

Moving Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23147    Accepted Submission(s): 7779 Problem Description The famous

保持对编程的热情! 1656

0009 用VisualStudio设计Max工具

这次分享个独家专利^)^:在Visual Studio中设计3dsMax脚本工具界面。 某次做原型设计时,需求改来改去,实在懒得搞GUI;虽然也尝试在Axure RP里画原型,但还是Visual Studio更顺手,也更容易测试一些交互,就直接在VS里做了。后来突发奇想,想实验一把能否直接用到Max里去,结果没想到成功了,效果还挺好。发现了新大陆,记录一下。   开始: 在VS里新建W...

whwst的专栏 770

delphi fmx android 自动更新(一)

所以,如果是http 则,manifest.xml application 下,https无需添加。增加android:usesCleartextTraffic="true",不然无法使用http下载东西。1,REQUEST_INSTALL_PACKAGES 权限。4,WRITE_EXTERNAL_STORAGE 权限。3,READ_EXTERNAL_STORAGE 权限。一般是从http下载安装包 apk。2,INTERNET 权限。sFile为apk包路径。

全粘工程师 550

hdu 1050 Moving Tables(贪心)

hdu 1050 Moving Tables(贪心) 添加链接描述 #include <bits/stdc++.h> using namespace std; #define MXN 210 int n, r[MXN<<1], c[MXN]; int main(){ int T, n, s, t; scanf("%d", &T); for(int i = 1; i <= 200; i++) r[i<<1] = i,

weixin_51663098的博客 142

高级数据库--作业及答案

中科大金培权老师的高级数据库课程作业及答案

一杯水果茶!足矣~ 1658

hdu 1050Moving Tables(uvaoj 2326)

点击打开链接

gwq5210的专栏 705

Python爬虫实战:抓取统计数据并生成年度对比图表详解

国家统计局网站(静态HTML页面Excel文件JSON接口(部分新版API)我们将重点演示从统计公报页面抓取数据,结合解析Excel文件,实现多种数据格式爬取处理。本文从零开始搭建了一个爬取国家统计数据并制作年度对比图表的完整流程。读者可以根据实际需求调整爬取目标,丰富数据分析维度,甚至结合机器学习模型预测未来趋势。欢迎你在评论区留言分享你的爬虫实践,或提出改进建议!

2201_76125261的博客 1001

优秀的 Verilog/FPGA开源项目介绍(二十六)- ISP (图像信号处理)

介绍查看《ISP算法及架构分析介绍》今天项目的顺序就是先介绍几个关于ISP算法架构的项目,包括python、matlab、c等高级语言实现的ISP算法架构,最后介绍一个FPGA实现ISP的项目。openISPhttps://github.com/cruxopen/openISP项目介绍用python实现的ISP架构,该架构涉及到的知识如下:下图是最新实现的模块:主要模块如...

OpenFPGA的博客 4948

HDU 1050 Moving Tables

http://acm.hdu.edu.cn/showproblem.php?pid=1050 题意:不占用通道就可以同时过,占用通道就不能同时过,问最短的时间全部搬完桌子。 贪心策略--每个房子前的通道用数组a[200]表示,占用通道就加+1;占用通道最大的数,就是最短的时间再乘以10; 需要注意的是房间与走廊的位置关系,就如图中所给的图片所示 相对门的两个房间占用同一处...

weixin_30508309的博客 75

uniapp [微信小程序] - 详解微信小程序端接入mqtt全流程及示例源码教程,uniApp微信小程序端如何接入MQTT插件并实现连接/断开+发布订阅+消息队列+离线重连等各种示例代码(开箱即用)

uniapp微信小程序接入MQTT,uniapp中使用mqtt,uniapp 微信小程序端接入mqtt示例代码教程,适用于微信小程序的MQTT插件,uniapp开发微信小程序连接mqtt,uniApp微信小程序接入MQTT协议,uniapp vue3微信小程序使用MQTT的小例子接入流程,使用uniapp开发小程序接入mqtt,如何在uniapp项目中使用mqtt,uniapp mqtt的使用示例,mqtt连接报错,如何在项目里集成mqtt,Mqtt协议,主动连接mqtt,订阅消息,实现发布,订阅和接收消息

🏆 前端领域优质创作者 2882

hdu 1050 Moving Tables(暴力)

//hdu 1050 Moving Tables(暴力) /* 题意:地板上有200个房间每一个在北面和南面沿着走廊。 最近公司做了一个改革计划系统。 改革包括房间之间移动大量的表。 因为走廊狭窄,所有的表都大,只有一个表可以通过走廊。 一些计划是需要提高运动效率。 经理想出了以下计划:将一个表从一个房间到另一个房间可以在10分钟内完成。 当移动表从一个房间i房间j,面前的空间之间的走廊的一部分i

u014068781的专栏 468

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

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

HDU1050 Moving Tables

  Moving TablesTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1715    Accepted Submission(s): 663Problem DescriptionThe famous ACM (Advan

Adam·Niuen 3130

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

HDU1050: Moving Tables(搬桌子)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050Moving TablesTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 40291    Accepted Submission(s):...

牛呆呆同学的博客 726

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

hdu1050Moving Tables

hdu1050      Moving Tables    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1050   贪心水题   题目大意:   著名的计算机(高级电脑制造商)公司租了一个楼层的建筑物,其形状面积描述如下:   这个楼层在沿着走廊的北面和南面有200个房间。最近该公司提出了计划改革系统。改革包括搬动客房里的多很桌子。由于走廊

slicer的技术交流栈 587

ACM-贪心之Moving Tables——hdu1050

Moving Tables Problem Description The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape is in the following figure. The floor has 200 rooms each

继续激情,继续奋斗。 3757

hdu 1050 Moving Tables

http://acm.hdu.edu.cn/showproblem.php?pid=1050 这个题我首先直接用的常规贪心,用的和那个尽可能看更多完整节目那种思路。但是。。。。。。。一直WA。。。。T_T。。。。 后来在网上搜了一下这个题,发现好多人都有问题,都没有求出来,基本上都用的对尾部排序求的方法。 其实这个题因为是两排走廊,所以1和2公用一个走廊,其中一个在需要移动的时候

蚕豆儿 781

hdu1050 Moving Tables

题目:http://acm.hdu.edu.cn/showproblem.php?pid=1050 求区间上点的最大重叠次数。 #include #include int main() { int t, s, e, i, n, max, tmp; int mark[205]; scanf("%d", &t); while (t--) {

天亮说晚安 1914

[ACM_HDU_1050]Moving Tables

Moving Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 9950 Accepted Submission(s): 3389 Description The famous ACM (Advanced Compu

279

hdu1050 Moving Tables解题报告

貌似很简单的一道题目,可我却用了好长时间,哎、、、得多练练啊,废话不多说了,写下分析和代码,思路: 假设从1->399(或者2->400)的走廊是一条线段,每搬一张桌子(如从30号房间搬到40号房间),则线段30->40被重复了一次。如果另外再搬一张桌子(如从35号房间搬到45号房间),则线段35->45被重复了一次。而相同的线段35->40则被重复了两次。问题转化为求最大重复次数。 那很好办

wei_xiaohui的专栏 2171
上一篇: HDU 1083 Courses
下一篇: Codeforces Round #137 (Div. 2), problem: (C)
E_Windrunner
博客等级 码龄15年 7粉丝 120原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值