#include <math.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include<iostream>
using namespace std;
#define N 50005
const double Pi = acos(-1.0);
struct Point
{
int x,y;
}P[N],S[N];
int n,top,L;
int Dis(const Point& p1,const Point& p2)
{
return (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) ;
}
double Cross(const Point& p1,const Point& p2,const Point& p3,const Point& p4)
{
return (p2.x-p1.x)*(p4.y-p3.y) - (p2.y-p1.y)*(p4.x-p3.x);
}
bool cmp(const Point& p1,const Point& p2)
{
double C = Cross(P[0],p1,P[0],p2);
return C ? C>0 : Dis(P[0],p1)>Dis(P[0],p2);
}
bool Cmp(Point x,Point y)
{
if(x.x!=y.x)
{
return x.x<y.x;
}
else if(x.x==y.x)
{
return x.y<y.y;
}
}
void Pole_Point()
{
int id;
Point pp = P[id=0];
for(int i=1;i<n;i++)
if(P[i].y < pp.y || P[i].y == pp.y && P[i].x < pp.x)
pp = P[i] , id = i;
P[id] = P[0] , P[0] = pp;
}
void Convex_Hull()
{
Pole_Point();
sort(P+1,P+n,cmp);
S[0]=P[0],S[1]=P[1],S[top=2]=P[2];
for(int i=3;i<n;i++)
{
while(top>0&&Cross(S[top-1],S[top],S[top],P[i]) < 0)
--top;
S[++top] = P[i];
}
}
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++)
scanf("%d%d",&P[i].x,&P[i].y);
Convex_Hull();
int ans =-99;
// S[top+1] = S[0];
for(int i=0;i<=top;++i)
for(int j=i+1;j<=top;j++)
{
if(Dis(S[i],S[j])>ans)
ans=Dis(S[i],S[j]);
}
printf("%d\n",ans);
return 0;
}
相关推荐
solidworks实体显示线框
solidworks实体莫名其妙显示为有点虚的线框
http://poj.org/problem?id=2192
方法一: #include #include #include using namespace std; char a[210]; char b[210]; char c[210]; bool can[210][210]; void init() { for (int i = 0; i < 210; i ++) { for (int j = 0; j < 210; j ++
深入解析UDS 0x19服务:DTC状态掩码与故障诊断实战
本文深入解析了UDS诊断协议中的核心0x19服务(ReadDTCInformation),重点拆解了DTC状态掩码(DTCStatusMask)的八个状态位及其在故障生命周期中的联动逻辑。通过实战案例,详细说明了从故障发生、确认到清除的全过程,并介绍了如何利用该服务进行深度诊断,包括读取扩展数据(如冻结帧)和避免常见开发误区,是理解汽车ECU故障管理机制的关键。
旋转卡壳求长度(凸包直径)
思路链接: https://blog.csdn.net/ACMaker/article/details/3177045 题目链接: http://poj.org/problem?id=2187 This is the codes: #include<algorithm> #include<cstdio> #include<cstring> #inc...
表格数据学习的图神经网络综述
今天学习一篇发表在中科院一区期刊《ACM Computing Surveys》的综述文章《Graph Neural Networks for Tabular Data Learning: A Survey with Taxonomy & Directions》,该刊主要刊载计算机理论方法领域的系统性综述与教程论文,注重跨学科技术融合研究,最新的影响因子为28.0。本文的目的在于通过学习这篇文章,了解关于表格数据学习点图神经网络一些基础知识。
别再手动调参了!用Optuna+PyTorch搞定Transformer时序预测超参数(附完整代码)
本文详细介绍了如何利用Optuna和PyTorch实现Transformer时序预测模型的自动化超参数调优。通过贝叶斯优化技术,显著提升单变量时序预测的效率和准确性,并附有完整代码实现。文章涵盖模型架构设计、数据预处理、Optuna调参实战及生产环境部署建议,为开发者提供一站式解决方案。
http://acm.hdu.edu.cn/showproblem.php?pid=2795区间最大值
刚开始时感觉本题是二维线段树,然后分析一下貌似不是,就是求取区间最大值的位置,感觉和之前的那道求逆序数的有一部分很像,查询更新;这题是把查询和更新合在了一起;但是我这个弱菜不会写代码,之后果断参考了HH神牛的模板;ORZ。。。各种若,弱不经风,刚学线段树,以后要努力,第一次这么晚了还在写代码了,ORZ。。只有我这种若才才会熬夜。。。 好了今天到这里一会碎觉喽,不然会挂的。这几天看到网上很多新闻因
Python+whisper/vosk实现语音识别
Whisper 是一个由 OpenAI 开发的人工智能语音识别模型,它能够将语音转换为文本。Whisper 模型特别之处在于它的设计目标是能够理解和转录多种语言的语音,包括但不限于英语。Whisper 模型在训练时使用了大量不同语言的语音数据,这使得它具有很好的跨语言能力。Vosk 是一个开源的语音识别库,它可以在离线环境下工作,不依赖于任何外部服务。Vosk 基于Kaldi语音识别框架,支持多种语言,包括中文。Vosk提供了多种预训练模型,可以根据需求选择适合的模型进行语音识别。
http://poj.org/problem?id=3468线段树简单 成段更新 区间求和
这题是昨天的比赛题,昨天比赛完美被大一的虐了,感觉自己真是白活了,一头撞死算了,人家大一的做了5题,而我这个水货这做了两道签到题;明显昨天知道这个题目是线段树,刚开始还想用树状数组试试,后来写完了发现不是插线问点,结果可想而知,代码重写,再看时线段树,然后不会了,自己只会单点更新,以后努力了,没有时间给自己犹豫了;抓紧时间学习数据结构,还有贪心,图论,搜索,还有C++;任重道远; 其中本题的延迟
从零构建:基于OpenCV与人体姿态分析的跌倒检测实战(附完整源码)
本文详细介绍了如何从零构建基于OpenCV与人体姿态分析的跌倒检测系统,包含完整源码与部署指南。通过MediaPipe实时检测33个人体关键点,结合多条件联合判断算法,实现高精度跌倒识别。文章还提供了性能优化技巧、常见问题解决方案以及家用与养老院两种部署方案,帮助开发者快速落地这一计算机视觉应用。
Simulink中通过MEX与MinGW实现C/C++结构体变量的高效导入
本文详细介绍了在Simulink中通过MEX工具链与MinGW编译器,高效导入C/C++结构体变量的完整流程。文章从需求背景出发,逐步讲解了MinGW环境配置、.h文件编写规范、核心导入命令Simulink.importExternalCTypes的使用,以及如何在MATLAB Function模块和总线创建器中调用自定义结构体,旨在实现模型与代码的无缝对齐,为后续仿真和代码生成奠定坚实基础。
给出一个n个元素的链表输出倒数第k个节点
用两个指针;初始化为头指针;用其中一个指针遍历链表,当该指针遍历到第k个节点时,另外一个指针开始从头节点开始遍历链表;两个指针之间的距离为k;遍历完链表时第二个指针所指向的节点就是倒数第K个: #include #include #include using namespace std; struct node{ int val; node *next; node(){
Python爬虫教程:如何爬取多平台电商商品信息(价格、评价、库存)
本文介绍了如何编写一个跨平台电商商品爬虫,爬取多个平台的商品信息,包括商品名称、价格、评价等数据。通过Python的爬虫库(如requestsSelenium)和数据处理库(如pandasmatplotlib)的结合,我们可以高效地获取和分析电商平台上的商品信息。
http://acm.nbut.cn/Problem/view.xhtml?id=1186二叉树的宽度
昨天比赛时我代码没有写出来还好思想有了,跟魁永说了,他也是这个想法;然后就做了,代码写了好久啊(感觉真是弱死了,而且wa了一次),今天自己写了1Y;感觉真是弱爆了;以后搜索要抓紧练习了; #include #include #include #include using namespace std; struct node { node() {lc=rc=-1;} int lc,rc; }
复分析 阿尔福斯(Ahlfors) 第三版答案 英文
答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案
深度学习工具包 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');```[](https://bitdeli.com/free "Bitdeli Badge")
C++中的static
在定义变量和函数时用关键字static用来修饰命名空间作用域的变量和函数时和extern的作用刚好相反; extern用法 但是这种方式在2003的c++ 2.0标准中已经宣布不再鼓励这种方式; 用的是匿名的命名空间,尼玛我是第一次听说这个匿名的命名空间,它是这样的; namespace{ int n; void f(){ n++; }
大中型超市收银系统(可直接运行)
光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开
C++ extern 关键字的用法
extern声明一个外部变量与外部函数: //源文件1 int i; //源文件2 extern int i;//声明一个在其他文件中定义的外部变量i;如果不写这个extern int i;源文件2是不能用文件1中的变量i的; 外部函数是在所有类外声明的函数(非成员函数),都是具有命名空间作用域的,如果没有特殊说明,这样的函数都可以在不同的编译单元中被调用,只要在调用之前有引用性声明即可,也可以在
STM32F407中文手册
STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。
月老的难题&&二分图最大匹配模板&&http://acm.nyist.net/JudgeOnline/problem.php?pid=239
二分图最大匹配:用邻接矩阵超时,需要用邻接表; #include #include #include #include #include #include using namespace std; const int N=512; bool chk[N]; vectorvis[N]; int n; int xM[N],yM[N]; bool SearchPath(int u) { int dd
http://lightoj.com/volume_showproblem.php?problem=1059最小生成树变形
利用kruscal求最小生成树,如果建一条路的费用超过建一个机场,就去掉该边(这点很关键); #include #include #include using namespace std; const __int64 N=10002; const int INF=9999999999; struct node { __int64 u,v; __int64 cost; }a[N*10]; __
http://poj.org/problem?id=1330&&大水货一个啊
LCA纯版题,各种调试不成功,砸电脑的心都有了;撞墙去了恶心死了; 更恶心的是vs2010报错:sbIDE #include #include #include #include #include using namespace std; const int MAX=10010; #define CLR(arr,val) memset(arr,val,sizeof(arr)) int n,f
C++自己写的非常简单的文件
以后我的定位就是用linux下的C/C++开发,现在开始复习C++了,虽然以前学过,而且自己在大一的第二学期就已经学了一点点,但是那都是皮毛,去年暑假学了一点点STL,自我感觉还不错,结果在大二第一学期的C++考试考得很烂,自己大二第一学期完全没有学到神马东西,虽说学了一点点的算法,但是还是很弱的; 头文件声明 //头文件声明 #ifndef SALE_H #define SALE_H c
unix 网路编程(卷一)第一个程序编译过程
unix网络编程
C++&&Mysql&&codeblocks
#include #include #include #include using namespace std; /*数据库连接用宏*/ #define HOST "localhost" #define USERNAME "root" #define PASSWORD "333333" #define DATABASE "test" void query_sql(char* sql)
http://poj.org/problem?id=2828线段树 逆序
尼玛线段树终于又有点进展了,果断的难,自己一直不知道在具体的问题中用线段树记录什么内容,看来还是做过的题目太少了,见过的类型很少,以后要努力了,这次必须把线段树专辑搞完在回家。。。。弱爆了。 这题刚开始看时完全不知道线段树记录什么内容,如何用线段树表示,更不知道如何下手了;后来看了别人的解题报告理解了好长时间,才明白,真心要努力了,多思考; 由于这题是插队的问题,要等所有信息输入完才知道最终结
并查集应用http://ac.nbutoj.com/Problem/view.xhtml?id=1187
并查集应用:ORZ。。。。无语了这一题写了快一下午,累的我要吐血了,浑身疼啊,,先是TLE,然后各种参考大神代码,尤其是骆神的。。。ORZ。。。。ORZ。。。 昨天比赛就是抱骆神大腿的,,,ORZ,骆神V587,ORZ......各种若斯。。。。#include #include #include using namespace std; struct node { int fa; bool
1万+



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



