QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225681 | #7584. Support or Not | PhantomThreshold | WA | 3589ms | 20816kb | C++14 | 2.5kb | 2023-10-24 22:56:01 | 2023-10-24 22:56:03 |
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];
int cnt=0;
vector<db> ans;
ll getid(ll x,ll y,ll z){
return (x<<40)|(y<<20)|(z);
}
void check(db mid,bool flag=0){
cnt=0;
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;
unordered_map<ll,vector<int>> nxtdict;
for (int j=1;j<i;j++){
ll id=getid(a[j].o.x/pre2R,a[j].o.y/pre2R,a[j].o.z/pre2R);
nxtdict[id].push_back(j);
}
nxtdict.swap(dict);
}
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){
if (flag) ans.push_back(d);
cnt++;
if (cnt==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,0);
// cerr << "l,r : " << l << " " << r << "\n";
// cerr << cnt << "\n";
if (cnt==k) r=mid;
else l=mid+1;
}
if (l>1){
check(l-1,1);
while (cnt!=k){
ans.push_back(l);
cnt++;
}
}
else{
ans.clear();
for (int i=1;i<=k;i++) ans.push_back(0);
}
sort(ans.begin(),ans.end());
for (auto e:ans) cout << e << "\n";
ans.clear();
}
int main(){
ios_base::sync_with_stdio(false);
int Tcase=3;
cin >> Tcase;
for (;Tcase--;){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3480kb
input:
1 4 6 0 0 0 1 0 3 2 2 3 2 1 1 1 1 2 2
output:
0 0 0 1 1 2
result:
ok 6 numbers
Test #2:
score: -100
Wrong Answer
time: 3589ms
memory: 20816kb
input:
3 100000 300 874914 604395 333852 94 487016 56485 38106 94 593651 138336 969260 37 353586 222361 911579 10 865600 791274 47766 5 22401 596667 465329 21 466027 350897 62260 16 728026 787017 272219 76 955473 207969 90699 18 252804 854316 349023 34 59964 288736 663393 72 667204 542533 993769 48 754023 ...
output:
181 217 321 348 384 416 418 428 446 456 550 593 646 650 668 692 721 733 756 773 808 858 860 865 875 909 916 930 931 935 938 947 959 974 981 1006 1033 1069 1071 1078 1086 1088 1097 1126 1126 1149 1153 1157 1160 1171 1198 1208 1217 1224 1228 1234 1252 1253 1275 1287 1307 1309 1334 1350 1354 1359 1366 ...
result:
wrong answer 594th numbers differ - expected: '1253', found: '1255'