UVA 1468 Restaurant ?
来源:互联网 发布:中科大算法导论 编辑:程序博客网 时间:2024/06/04 08:49
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define rep(i,a,b) for(int i=(a);i<(b);i++)#define ss(x) scanf("%d",&x)const int maxn=60000+10;int y,ax,ay,bx,by,m,n,h[maxn];int main(){ int t; ss(t); while(t--) { ss(m);ss(n); int a,b; ss(ax);ss(ay);ss(bx);ss(by); if(ax>bx) swap(ax,bx); y=ay; memset(h,0x7f,sizeof(h)); rep(i,2,n) {ss(a);ss(b);h[a]=min(h[a],abs(y-b));} h[ax]=h[bx]=0; rep(i,ax+1,bx) h[i]=min(h[i],h[i-1]+1); for(int i=bx;i>ax;i--) h[i]=min(h[i],h[i+1]+1); int ans=0; rep(i,ax+1,bx) if(h[i]) ans+=min(h[i]-1,y)+min(h[i]-1,m-y-1)+1; cout<<ans<<endl; } return 0;}
0 0
- UVA 1468 Restaurant ?
- UVA 1468 - Restaurant(推理)
- uva 1468 - Restaurant(贪心)
- UVaLive 4851 UVa 1468 - Restaurant (思维)
- UVa 1468 - Restaurant(贪心 + 扫描)
- ACM: uva 1468 - Restaurant
- Restaurant
- Restaurant
- Restaurant
- Restaurant LA4851
- Uva1468 Restaurant
- Restaurant Menus
- I - Restaurant
- I - Restaurant
- Restaurant--贪心
- 【codeforces】Restaurant
- Restaurant Simulation
- Restaurant Tables
- ListView分页
- ActivityRouter
- BadBoy 手册
- zookeeper在window下使用
- 服务器是否支持断点续传
- UVA 1468 Restaurant ?
- 一款在线视频 App,基于 Material Design + MVP + RxJava + Retrofit + Realm + Glide
- ContentProvider和Uri详解
- UIWebView禁用长按选中复制等功能
- 四种常见的 POST 提交数据方式
- 扩展activiti-userTask分配多个角色
- __attribute__((packed))详解
- 前端用书常见类
- OR卷积