QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575749#9316. BoxesSusie_RainWA 89ms4348kbC++204.1kb2024-09-19 16:36:462024-09-19 16:36:46

Judging History

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

  • [2024-09-19 16:36:46]
  • 评测
  • 测评结果:WA
  • 用时:89ms
  • 内存:4348kb
  • [2024-09-19 16:36:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define debug(x) cout<<x<<"--------------------------------------\n" ;
const int N = 1e5 + 10;
typedef long long ll;
const int INF = 1e9 ;
const int MOD = 1e9 + 7 ;
typedef pair<int,int> PII ;
int gcd(int a,int b){
    return b ? gcd(b,a%b) : a ;
}
ll qpow(int a,int k){
    ll res = 1 ;
    while (k){
        if(k&1) res = 1ll * res * a % MOD ;
        a = 1ll * a * a % MOD ;
        k >>= 1 ;
    }
    return res ;
}
#define double long long
const double eps=0;
const double PI=acos(-1);
inline int sgn(double x){
    return fabs(x)<=eps?0:(x<0?-1:1);
}
double ans2 = 0;
struct point3{
    double x,y,z;
    point3(double a=0,double b=0,double c=0):x(a),y(b),z(c){}
    point3 operator +(const point3 &A)const{
        return point3(x+A.x,y+A.y,z+A.z);
    }
    point3 operator -(const point3 &A)const{
        return point3(x-A.x,y-A.y,z-A.z);
    }
    point3 operator *(const double v)const{
        return point3(x*v,y*v,z*v);
    }
    point3 operator /(const double v)const{
        return point3(x/v,y/v,z/v);
    }
    bool operator ==(const point3 &A)const{
        return sgn(x-A.x)==0&&sgn(y-A.y)==0&&sgn(z-A.z)==0;
    }
    double length(){
        return sqrt(x*x+y*y+z*z);
    }
    point3 unit(){
        return *this/length();
    }
};
point3 det(point3 a,point3 b){
    return point3(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}
ll dot(point3 a,point3 b){
    return a.x*b.x+a.y*b.y+a.z*b.z;
}
//除以6就是a,b,c三个向量所构成的四面体的体积
double mix(point3 a,point3 b,point3 c){
    return dot(a,det(b,c));
}
struct plane{
    point3 v[3];
    plane() {}
    plane(point3 uu,point3 vv,point3 ww) {v[0]=uu,v[1]=vv,v[2]=ww;}
    point3 normal() {return det((v[1]-v[0]),(v[2]-v[0]));}
};
ll ans;
ll Volume(point3 a,point3 b,point3 c,point3 d){
    return dot(det(b-a,c-a) ,(d-a));
}
namespace CH3{
    vector<vector<point3>> ret;
    set<pair<int,int> > eg;
    set<int> pt;
    int n;
    vector<point3> p,q;

    void wrap(int a,int b){
        if (eg.find({a,b})==eg.end()){
            int c=-1;
            for (int i=0;i<n;i++)if (i!=a && i!=b){
                    if (c==-1 || Volume(q[c],q[a],q[b],q[i])>0)
                        c=i;
                }
            if (c!=-1){
                ans2 += det(p[b]-p[a],p[b]-p[c]).length()/2;
//                debug(1)
//                cout << ans2 << '\n';
//                cout << p[a].x << ' ' << p[a].y << ' ' << p[a].z << '\n';
//                cout << p[b].x << ' ' << p[b].y << ' ' << p[b].z << '\n';
//                cout << p[c].x << ' ' << p[c].y << ' ' << p[c].z << '\n';
                ans+=Volume(point3(0,0,0),p[a],p[b],p[c]);
                ret.push_back({p[a],p[b],p[c]});
                pt.insert(a); pt.insert(b); pt.insert(c);
                eg.insert({a,b});eg.insert({b,c});eg.insert({c,a});
                wrap(c,b);wrap(a,c);
            }
        }
    };

    vector<point3> convexHull3d(vector<point3> _p){
        p = q = _p; n = p.size();
        ret.clear(); eg.clear(); pt.clear();
        //ans=0;
        for (int i=1;i<n;i++)if (q[i].x<q[0].x)swap(p[0],p[i]),swap(q[0],q[i]);
        for (int i=2;i<n;i++)if (
                    (q[i].x-q[0].x)*(q[1].y-q[0].y)>
                    (q[i].y-q[0].y)*(q[1].x-q[0].x)) swap(q[1],q[i]),swap(p[1],p[i]);
        wrap(0,1);
        vector<int> pc(pt.begin(),pt.end());
        reverse(pc.begin(),pc.end());
        for (auto x:pc) {
            q.erase(q.begin()+x);
        }
//        cout << ans2 << '\n';
        return q;
    }
}
void solve(){
    int n;cin >> n;
    ans = 0;
    vector<point3> p;
    for(int i=0;i<n;i++){
        double x , y , z; cin >> x >> y >> z;
        p.push_back({x,y,z});
    }
    while (p.size() >= 4){
        p = CH3::convexHull3d(p);
    }
//    cout << fixed << setprecision(3);
//    cout << ans2 << '\n';
    cout << ans << '\n';
}
signed main(){
    ios::sync_with_stdio(false) ;
    cin.tie(0) ;
    int tt = 1 ;
    cin >> tt ;
    while (tt--) solve() ;
    return 0 ;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3664kb

input:

2
4
0 0 1
0 0 2
0 1 1
1 1 1
10
2 6 3
2 9 0
2 1 0
3 7 3
0 5 6
10 9 2
4 4 2
8 5 2
4 6 9
6 7 5

output:

1
943

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 7ms
memory: 3720kb

input:

30
100
214848 13593 883915
404922 704679 762266
19696 348707 172137
204169 674312 980107
159743 683657 537795
913278 244484 331997
342255 150373 745862
822992 993127 812010
78019 523301 874868
508779 130959 577626
506563 15210 31018
302821 671498 135922
379735 258803 474373
387144 676958 499943
9009...

output:

8466306477510658674
7272556711339503943
7635348833914404146
8107228712222480162
8154398837331856360
7551703717471512369
8340343101157128252
7911868248459799324
7911957494280349996
8295429352750849603
8170150524727285883
7448641514858636645
8373196774630538132
7404986332777191754
7496214926512003280
...

result:

ok 30 lines

Test #3:

score: 0
Accepted
time: 3ms
memory: 3632kb

input:

300
10
284000 364959 249145
243447 261451 165064
884086 450907 263262
986606 115922 516435
550174 625062 491782
992985 764800 854837
992741 919628 758329
114851 373304 743149
236804 572126 522753
694056 863964 768484
10
328584 59621 865079
133943 928163 534857
746608 698892 195503
199343 568337 4820...

output:

803077918387863438
484728351097401010
1106436691630702280
544591678232219117
1068791025597242587
930320279051363466
977769839732812040
699051820151945692
1140525392772278038
1116781785107680980
844917700022644714
672066651386061967
638048751063849731
1258576451479348061
476673417837522259
8473170752...

result:

ok 300 lines

Test #4:

score: -100
Wrong Answer
time: 89ms
memory: 4348kb

input:

1
3000
413652 522034 362874
161444 14592 423619
276585 592939 402025
969689 188554 136993
462321 11911 652603
155677 401331 635931
339965 202216 204346
992462 357822 565008
886658 168024 940016
767608 638795 810396
137017 720592 591380
131999 195424 726856
127795 754489 391676
201652 890036 283312
2...

output:

4933347942154243019

result:

wrong answer 1st lines differ - expected: '60273580163282897867', found: '4933347942154243019'