QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#220126 | #7584. Support or Not | PhantomThreshold# | WA | 3235ms | 10924kb | C++20 | 3.1kb | 2023-10-19 22:31:18 | 2023-10-19 22:31:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sq(ll x){
ll sz=sqrtl(x);
for (;(sz)*(sz)<x;) sz++;
for (;(sz-1)*(sz-1)>=x;) sz--;
return sz;
}
ll calc(ll x,ll y,ll z){
ll w2=x*x+y*y+z*z;
ll sz=sq(w2);
return sz;
}
typedef double 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 hypot(hypot(x,y),z);}
point unit(){
db w=abs();
return (point){x/w,y/w,z/w};
}
};
db dot(point k1,point k2){
return k1.x*k2.x+k1.y*k2.y+k1.z*k2.z;
}
const int maxn=100000;
const int maxk=300;
mt19937 rng((unsigned long long)(new char));
db pi=acos(-1);
db scale=0.5;
const int magicD=600;
int n,k;
ll _x[maxn+50],_y[maxn+50],_z[maxn+50];
point a[maxn+50];
ll r[maxn+50];
vector<tuple<ll,int,int>> candidate;
ll ans[maxk+50];
pair<db,db> b[maxn+50];
tuple<db,int,int> mn[magicD+5];
int mn_sz=0;
tuple<db,int,int> nxt[magicD+5];
int nxt_sz=0;
void gao(point dir){
for (int i=1;i<=n;i++){
db mid=dot(a[i],dir);
b[i]=make_pair(mid-scale*r[i],mid+scale*r[i]);
}
sort(b+1,b+n+1);
// cerr << "ok1" << endl;
for (int i=1;i<n;i++){
// cerr << "gao : " << i << endl;
int mn_pos=1;
nxt_sz=0;
for (int j=i+1;j<=i+magicD && j<=n;j++){
db proj_dis=b[j].first-b[i].second;
while (mn_pos<=mn_sz){
if (nxt_sz==magicD) break;
if (get<0>(mn[mn_pos])<proj_dis){
nxt[++nxt_sz]=mn[mn_pos];
}
else break;
mn_pos++;
}
if (nxt_sz==magicD) break;
nxt[++nxt_sz]=make_tuple(proj_dis,i,j);
}
while (mn_pos<=mn_sz){
if (nxt_sz==magicD) break;
nxt[++nxt_sz]=mn[mn_pos];
mn_pos++;
}
// cerr << "mn_sz,nxt_sz : " << mn_sz << " " << nxt_sz << endl;
mn_sz=nxt_sz;
for (int t=1;t<=nxt_sz;t++) mn[t]=nxt[t];
}
// cerr << "ok2" << endl;
for (int sel=1;sel<=mn_sz;sel++){
int i=get<1>(mn[sel]);
int j=get<2>(mn[sel]);
ll d=calc(_x[i]-_x[j],_y[i]-_y[j],_z[i]-_z[j])-r[i]-r[j];
d=max(d,(ll)0);
candidate.emplace_back(d,i,j);
}
}
void solve(){
cin >> n >> k;
for (int i=1;i<=n;i++){
int _r=0;
cin >> _x[i] >> _y[i] >> _z[i] >> _r;
a[i].x=_x[i];
a[i].y=_y[i];
a[i].z=_z[i];
r[i]=_r;
}
for (int cc=1;cc<=16;cc++){
point dir;
dir.x=(int)(rng()%20000001)-10000000;
dir.y=(int)(rng()%20000001)-10000000;
dir.z=(int)(rng()%20000001)-10000000;
while (dir.abs()>10000000){
dir.x=(int)(rng()%20000001)-10000000;
dir.y=(int)(rng()%20000001)-10000000;
dir.z=(int)(rng()%20000001)-10000000;
}
dir=dir.unit();
gao(dir);
}
// cerr << "candy size :" << candidate.size() << endl;
sort(candidate.begin(),candidate.end());
candidate.resize(
unique(candidate.begin(),candidate.end())
-candidate.begin()
);
// cerr << "candy size :" << candidate.size() << endl;
for (int i=0;i<k;i++){
ans[i]=get<0>(candidate[i]);
}
for (int i=0;i<k;i++){
cout << ans[i] << "\n";
}
}
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: 0ms
memory: 7952kb
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: 3235ms
memory: 10924kb
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:
61377 69453 85410 86606 87286 87485 90489 90749 104726 106962 107844 110785 115235 116192 116343 117520 120111 123135 127373 133930 145320 147650 148392 150878 150933 151814 155666 155735 157708 162037 162445 166161 167442 168020 170839 172306 177116 179206 181778 181832 183218 185554 186535 187644 ...
result:
wrong answer 1st numbers differ - expected: '181', found: '61377'