Submission #1131044

#TimeUsernameProblemLanguageResultExecution timeMemory
1131044huutuanIOI 바이러스 (JOI21_fever)C++20
37 / 100
5088 ms6516 KiB
#include <bits/stdc++.h> using namespace std; #define int long long struct Point{ int x, y; Point (int _x=0, int _y=0){ x=_x, y=_y; } Point operator+(Point &a){ return Point(x+a.x, y+a.y); } Point operator-(Point &a){ return Point(x-a.x, y-a.y); } Point operator*(int d){ return Point(x*d, y*d); } }; const int N=1e5+10; int n; Point a[N], b[N]; int f[N]; int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i=1; i<=n; ++i) cin >> a[i].x >> a[i].y; // for (int i=1; i<=n; ++i) cout << (a[i]-a[1]).x << ' ' << (a[i]-a[1]).y << '\n'; for (int i=n; i>=1; --i) a[i]=(a[i]-a[1])*2; int ans=0; auto calc=[&](){ for (int i=1; i<=n; ++i){ if (a[i].y>=a[i].x && a[i].y<=-a[i].x) b[i]=Point(1, 0); else if (a[i].y<=-a[i].x) b[i]=Point(0, 1); else if (a[i].y>=a[i].x) b[i]=Point(0, -1); else b[i]=Point(-1, 0); } priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; memset(f, 0x3f, sizeof f); f[1]=0; pq.emplace(0, 1); while (pq.size()){ int i=pq.top().second, d=pq.top().first; pq.pop(); if (f[i]!=d) continue; for (int j=1; j<=n; ++j) if (i!=j){ int t=(abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y))/2; if (t<d || f[j]<=t) continue; bool check=0; if (a[i].x==a[j].x){ check=(a[i].y<a[j].y && b[i].y==1 && b[j].y==-1) || (a[i].y>a[j].y && b[j].y==1 && b[i].y==-1); }else if (a[i].y==a[j].y){ check=(a[i].x<a[j].x && b[i].x==1 && b[j].x==-1) || (a[i].x>a[j].x && b[j].x==1 && b[i].x==-1); }else if (a[i].x-a[i].y==a[j].x-a[j].y){ check=(a[i].x<a[j].x && ((b[i].x==1 && b[j].y==-1) || (b[i].y==1 && b[j].x==-1))) || (a[i].x>a[j].x && ((b[j].x==1 && b[i].y==-1) || (b[j].y==1 && b[i].x==-1))); }else if (a[i].x+a[i].y==a[j].x+a[j].y){ check=(a[i].x<a[j].x && ((b[i].x==1 && b[j].y==1) || (b[i].y==-1 && b[j].x==-1))) || (a[i].x>a[j].x && ((b[j].x==1 && b[i].y==1) || (b[j].y==-1 && b[i].x==-1))); } if (check){ f[j]=t; pq.emplace(t, j); } } } // for (int i=1; i<=n; ++i) if (f[i]<1e18) cout << i << ' '; // cout << '\n'; ans=max(ans, accumulate(f+1, f+n+1, 0ll, [&](int x, int y){ return x+(y<1e18); })); }; auto rotate=[&](){ for (int i=1; i<=n; ++i) a[i]=Point(-a[i].y, a[i].x); }; for (int i=1; i<=4; ++i){ calc(); rotate(); } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...