标签:代码 efi doc origin mes cin cout code max
http://www.doc88.com/p-9042008501060.html
论文说的很清楚
附送代码
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<queue> #include<map> #include<set> #include<list> #include<ctime> #include<ctype.h> #include<bitset> #include<algorithm> #include<numeric> //accumulate #define endl "\n" #define fi first #define se second #define FOR(i,s,t) for(int i=(s);i<=(t);++i) #define mem(a,b) memset(a,b,sizeof(a)) using namespace std; const int maxn=100000+10; int n,w,h; struct Node { int x,y; }; Node p[maxn]; int main() { //cout<<mid(25,5)<<endl; //cin.tie(0); //cout.tie(0); //ios_base::sync_with_stdio(false); //freopen("in.txt","r",stdin); //freopen("out.txt","w",stdout); int T; cin>>T; while(T--) { cin>>n>>w>>h; for(int i=0; i<n; i++) { int x,y; cin>>x>>y; p[i]= {x,y}; } p[n++]= {0,0},p[n++]= {w,h},p[n++]= {w,0},p[n++]= {0,h}; sort(p,p+n,[](Node x,Node y) { return x.x<y.x; }); int ans_x=1,ans_y=1,ans_l=1; for(int i=0; i<n; i++) { int up=h,down=0; for(int j=i+1; j<n; j++) { if(p[j].x==p[i].x) continue; int ly=up-down; int lx=p[j].x-p[i].x; int ans=min(lx,ly); if(ans>ans_l) { ans_l=ans; ans_x=p[i].x; ans_y=down; } if(p[i].y==p[j].y) break; if(p[j].y>p[i].y) up=min(up,p[j].y); if(p[j].y<p[i].y) down=max(down,p[j].y); } } for(int i=n-1; i>=0; i--) { int up=h,down=0; for(int j=i+1; j<n; j++) { if(p[j].x==p[i].x) continue; int ly=up-down; int lx=p[j].x-p[i].x; int ans=min(lx,ly); if(ans>ans_l) { ans_l=ans; ans_x=p[i].x; ans_y=down; } if(p[i].y==p[j].y) break; if(p[j].y>p[i].y) up=min(up,p[j].y); if(p[j].y<p[i].y) down=max(down,p[j].y); } } sort(p,p+n,[](Node x,Node y) { return x.y<y.y; }); for(int i=0; i<n; i++) { int j=i; while(j<n&&p[j].y==p[i].y) j++; if(j==n) break; int len=min(p[j].y-p[i].y,w); if(len>ans_l) { ans_l=len; ans_x=0; ans_y=p[i].y; } } cout<<ans_x<<‘ ‘<<ans_y<<‘ ‘<<ans_l<<endl; if(T) cout<<endl; } } /* void read() { char c = getchar(); int x = 0; for (; (c < 48 || c>57); c = getchar()); for (; c > 47 && c < 58; c = getchar()) { x = (x << 1) + (x << 3) + c - 48; } return x; } */
标签:代码 efi doc origin mes cin cout code max
原文地址:https://www.cnblogs.com/033000-/p/10640020.html