QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#225636 | #7584. Support or Not | PhantomThreshold | WA | 0ms | 3816kb | C++14 | 2.3kb | 2023-10-24 21:45:39 | 2023-10-24 21:45:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll ceilsq(ll x){
ll sz=sqrtl(x);
for (;(sz)*(sz)<x;) sz++;
for (;(sz-1)*(sz-1)>=x;) sz--;
return sz;
}
typedef long long db;
struct point{
db x,y,z;
point operator + (const point &k1){return (point){x+k1.x,y+k1.y,z+k1.z};}
point operator - (const point &k1){return (point){x-k1.x,y-k1.y,z-k1.z};}
db abs(){return ceilsq(x*x+y*y+z*z);}
db abs2(){return x*x+y*y+z*z;}
db dis(point k){return ((*this)-k).abs();}
db dis2(point k){return ((*this)-k).abs2();}
};
struct circle{
point o;
db r;
};
const int maxn=100000;
const int base=1000001;
int n,k;
circle a[maxn+50];
vector<db> ans;
ll getid(ll x,ll y,ll z){
return (x*base+y)*base+z;
}
void check(db mid){
ans.clear();
db pre2R=2e9;
unordered_map<ll,vector<int>> dict;
for (int i=1;i<=n;i++){
if (a[i].r*4+mid*2<pre2R){
pre2R=a[i].r*2+mid;
dict.clear();
for (int j=1;j<i;j++){
ll id=getid(a[j].o.x,a[j].o.y,a[j].o.z);
dict[id].push_back(j);
}
}
ll nowx=a[i].o.x/pre2R;
ll nowy=a[i].o.y/pre2R;
ll nowz=a[i].o.z/pre2R;
for (ll dx=-1;dx<=1;dx++){
if (nowx+dx<0) continue;
for (ll dy=-1;dy<=1;dy++){
if (nowy+dy<0) continue;
for (ll dz=-1;dz<=1;dz++){
if (nowz+dz<0) continue;
ll id=getid(nowx+dx,nowy+dy,nowz+dz);
if (dict.count(id)){
for (auto j:dict[id]){
db d=a[i].o.dis(a[j].o)-a[i].r-a[j].r;
d=max(d,(db)0);
if (d<=mid){
ans.push_back(d);
if ((int)ans.size()==k) return;
}
}
}
}
}
}
ll id=getid(nowx,nowy,nowz);
dict[id].emplace_back(i);
}
}
void solve(){
cin >> n >> k;
for (int i=1;i<=n;i++)
cin >> a[i].o.x >> a[i].o.y >> a[i].o.z >> a[i].r;
sort(a+1,a+n+1,
[&](const circle &A,const circle &B){
return A.r>B.r;
}
);
db l=0,r=1e7;
while (l<r){
db mid=(l+r)/2;
check(mid);
if ((int)ans.size()==k) r=mid;
else l=mid+1;
}
if (l>1){
check(l-1);
while ((int)ans.size()!=k) ans.push_back(l);
}
sort(ans.begin(),ans.end());
for (auto e:ans) cerr << e << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
int Tcase=3;
cin >> Tcase;
for (;Tcase--;){
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3816kb
input:
1 4 6 0 0 0 1 0 3 2 2 3 2 1 1 1 1 2 2
output:
result:
wrong answer Answer contains longer sequence [length = 6], but output contains 0 elements