2019-06-08 01:26:49 C++

C++

Copy Copied! Full
#include <bits/stdc++.h> using namespace std; struct C{ int x; int y; }; int main(void){ vector<vector<int>> x(5005); C C[5005]; int n,ans=0; int ax,ay,bx,by,cx,cy,dx,dy; cin >> n; for(int i=0;i<n;i++){ int tx,ty; cin >> tx >> ty; x[tx].push_back(ty); C[i].x= tx; C[i].y= ty; } for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ ax = C[i].x;ay = C[i].y; bx = C[j].x;by = C[j].y; cx = bx-by+ay; cy = by+bx-ax; dx = ax-by+ay; dy = ay+bx-ax; //cx,cy, dx dy が存在するかどうか調べる bool cok = 0, dok = 0; for(int c=0;c<x[cx].size();c++){ if(x[cx][c]==cy){ cok=1; break; } } for(int c=0;c<x[dx].size();c++){ if(x[dx][c]==dy){ dok=1; break; } } if(cok*dok){ ans = max(ans,(ax-bx)*(ax-bx)+(ay-by)*(ay-by)); } } } cout << ans << endl; }
RECOMMEND