您的位置:首页 > 其它

2013ACM-ICPC杭州赛区全国邀请赛总结

2013-08-10 21:09 381 查看
A.Robot(hdu 4576)

思路:

  直接暴力之...现场赛的时候被这题坑成狗,怎么算复杂度也不够...求300MS的解法T^T

#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include <map>
#include <set>
using namespace std;
struct Point{
int id,x;
bool operator <(const Point & tem)const{
return x<tem.x;
}
};
set<Point>q;
int main()
{
int n,Id,num;
while(scanf("%d",&n)!=EOF)
{
if(n==0) break;
Point hehe;
hehe.id=1;
hehe.x=1000000000;
q.clear();
q.insert(hehe);
for(int i=2;i<=n+1;i++)
{
scanf("%d%d",&Id,&num);
hehe.id=Id;
hehe.x=num;
set<Point>::iterator now =q.lower_bound(hehe),tem1,tem2;
tem1=tem2=now;
if(tem1!=q.begin())tem1--;
int va1=(num-tem1->x),va2=(tem2->x-num);
if(va2<va1)
printf("%d %d\n",Id,tem2->id);
else
printf("%d %d\n",Id,tem1->id);
q.insert(hehe);
}
}
return 0;
}


hdu 4585

  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: