QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#473367 | #22. Power plants | Mathias | 0 | 5ms | 7876kb | C++20 | 1.9kb | 2024-07-12 02:27:05 | 2024-07-12 02:27:05 |
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pb push_back
#define fi first
#define sc second
#define vi vector<int>
#define pii pair<ll,ll>
#define vpi vector<pair<ll,ll> >
const ll MOD1 = 1e9+7;
const ll MOD2 = 998244353;
const ll MOD3 = 1e9+93;
const ll MOD4 = 1e9+97;
const ll p1 = 1e9+87;
const ll p2 = 1e9+9;
const ll INF = 1e18+7;
const int BASE = 1<<20;
const int LOG = 20;
const int ALF = 27;
const int MAXN = 1e6+7;
const int MAXNN = 1e3+7;
pii t[MAXN]; bool vis[MAXN],k[MAXN],xd; pii p; int depth[MAXN];
vi g[MAXN]; int usu,n;
struct str{ll fi,sc,th;};
vector<str>pkt;
bool comp(str a,str b){
if(a.fi==b.fi) return a.sc<b.sc;
else return a.fi<b.fi;
}
set<pii>s;
ll d(int x,int y){ return (t[x].fi-t[y].fi)*(t[x].fi-t[y].fi)+(t[x].sc-t[y].sc)*(t[x].sc-t[y].sc); }
void DFS(int x,int f){
k[x]=1-k[f], vis[x]=1, depth[x]=depth[f]+1;
for(auto s1:g[x]) if(vis[s1]==1 and s1!=f and (depth[x]-depth[s1])%2==0) xd=(k[x]!=k[s1]); else if(vis[s1]==0) DFS(s1,x);
}
bool f(ll mid){
xd=1; usu=0;
for(int i=0;i<pkt.size();i++){
ll x=pkt[i].fi, y=pkt[i].sc;
while(pkt[usu].fi<x-mid) s.erase({pkt[usu].sc,pkt[usu].th}), usu++;
p={y-mid,0};
auto it=s.lower_bound(p);
for(auto curr=it;curr!=s.end();curr++){
p=*curr;
if(p.fi>y+mid) break;
if(d(p.sc,pkt[i].th)<mid) g[pkt[i].th].pb(p.sc), g[p.sc].pb(pkt[i].th);
}
s.insert({y,pkt[i].th});
}
s.clear();
DFS(1,0);
for(int i=0;i<pkt.size();i++) g[pkt[i].th].clear(), vis[pkt[i].th]=0;
return xd;
}
void solve(){
ll b=0,e=INF,mid,r=0;
cin>>n;
for(int i=1;i<=n;i++) cin>>t[i].fi>>t[i].sc, pkt.pb({t[i].fi,t[i].sc,i});
sort(pkt.begin(),pkt.end(),comp);
while(b<=e){
mid=(b+e)/2;
if(f(mid)) r=mid, b=mid+1; else e=mid-1;
}
cout<<r<<'\n';
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int tt=1;
while(tt--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 7876kb
input:
100 387 501 90 108 273 76 754 365 121 556 102 401 831 215 841 829 424 690 17 35 10 980 34 917 948 478 766 818 55 588 510 772 16 511 499 323 632 554 461 454 281 247 720 575 994 720 739 30 989 992 507 557 665 621 356 398 161 822 906 556 189 835 208 500 628 829 402 969 804 155 697 581 107 630 102 568 3...
output:
1802
result:
wrong answer
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%