QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#220141 | #7584. Support or Not | PhantomThreshold# | WA | 3091ms | 10876kb | C++20 | 3.1kb | 2023-10-19 22:37:03 | 2023-10-19 22:37:03 |
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=1200;
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<=8;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: 1ms
memory: 7884kb
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: 3091ms
memory: 10876kb
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:
61725 66280 67463 67669 69879 72239 86099 100248 102917 104181 107970 107971 109609 111196 112307 112666 116637 121354 122275 122721 122791 122968 123106 123670 127398 127427 127862 127867 128797 131740 132183 133880 133930 134657 135022 136284 136987 138431 139304 141883 142320 145481 145991 146389...
result:
wrong answer 1st numbers differ - expected: '181', found: '61725'