QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#197745#6407. Classical A+B Problemucup-team870#RE 0ms0kbC++141.9kb2023-10-02 19:18:082023-10-02 19:18:08

Judging History

你现在查看的是最新测评结果

  • [2023-10-02 19:18:08]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-02 19:18:08]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<=r; i++)
#define per(i,r,l) for(int i=r; i>=l; i--)
#define IOS {cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);}
using namespace std;
typedef long long ll;
#define db long double
#define eps 1e-8
#define ze(x) (abs(x)<=eps)
struct P{
    db v[3];
}A,E;
db dis(P a,P b){
    db res=0;
    rep(i,0,2)res+=(a.v[i]-b.v[i])*(a.v[i]-b.v[i]);
    return sqrt(res);
}
P operator *(P a,db k){
    rep(i,0,2)a.v[i]*=k;
    return a; 
}
P operator +(P a,P b){
    rep(i,0,2)a.v[i]+=b.v[i]; return a;
}
P operator -(P a,P b){
    rep(i,0,2)a.v[i]-=b.v[i]; return a;
}
P res[11]; db d[11]; int cnt;
int di(db v){
    return (int)(v+0.5);
}
void wk(P u,P v,P pt){
    assert(++cnt<=10);
    d[cnt]=dis(u,v); res[cnt]=v;
}
void wk2(P pt,int idx){
    P D=E; D.v[idx]=0;
    if(ze(dis(D,pt))){
        wk(A,D,pt);return;
    }
    db ma=-1; int id;
    P vec=D-pt;
    rep(i,0,2){
        if(i==idx)continue;
        if(vec.v[i]>ma){
            ma=vec.v[i]; id=i;
        }
    }
    P p=D-vec*(255/ma);
    P C=D; C.v[id]=0;
    wk(A,C,p); wk(p,D,pt);
}
void wk3(P pt){
    if(ze(dis(E,pt))){
        wk(A,E,pt); return;
    }
    P vec=E-pt;
    db ma=-1; int idx;
    rep(i,0,2){
        if(vec.v[i]>ma){
            ma=vec.v[i]; idx=i;
        }
    }
    P p=E-vec*(255/ma);
    wk2(p,idx);
    wk(p,E,pt);
}
void slv(){
    P pt; rep(i,0,2)cin>>pt.v[i];
    cnt=0;
    wk3(pt);
    cout<<cnt<<'\n';
    P now=A;
    rep(i,1,cnt){
        rep(j,0,2)cout<<di(res[i].v[j])<<' ';
        cout<<d[i]<<'\n';
        now=now+(res[i]-now)*d[i];
    }   
    assert(ze(dis(now,pt)));
}
int main() {
    // IOS 
    cout<<fixed<<setprecision(10);
    A={0,0,0};
    E={255,255,255};
    int T;cin>>T;
    while(T--)slv();    
}
/*
1

3
105 255 175
3
0 0 255 255.0000000000
0 255 255 255.0000000000
255 255 255 296.7556285249
*/

詳細信息

Test #1:

score: 0
Runtime Error

input:

6
2
786
1332
89110
2333333
10000000000000000000000000001

output:


result: