QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#220125 | #7584. Support or Not | PhantomThreshold# | WA | 3244ms | 10792kb | C++20 | 3.0kb | 2023-10-19 22:26:47 | 2023-10-19 22:26:47 |
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.515709995651;
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()%2001)-1000;
dir.y=(int)(rng()%2001)-1000;
dir.z=(int)(rng()%2001)-1000;
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7868kb
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: 3244ms
memory: 10792kb
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:
31918 44275 55170 65671 76093 81835 82920 84107 87350 95854 106486 109617 113419 114448 118462 122737 127572 131084 132702 133856 135022 141071 143618 143956 144129 145000 149475 156048 157154 157443 162427 166054 172806 176244 177164 178007 178197 182094 184062 186494 186653 189272 189514 193358 19...
result:
wrong answer 1st numbers differ - expected: '181', found: '31918'