QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#361216#4573. Global Warmingmc020207#Compile Error//C++173.7kb2024-03-22 22:35:002024-03-22 22:35:01

Judging History

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

  • [2024-03-22 22:35:01]
  • 评测
  • [2024-03-22 22:35:00]
  • 提交

answer

#include <bits/stdc++.h>
#define For(i, a, b) for(int i = (a); i <= (b);i++)
#define Rof(i, a, b) for(int i = (a); i >= (b);i--)
#define ll long long
#define lll __int128_t
#define db double
#define pii pair<int,int>
using namespace std;
template<class T1,class T2> void chkmin(T1 &x,T2 y){if(y<x)x=y;}
template<class T1,class T2> void chkmax(T1 &x,T2 y){if(y>x)x=y;}
const int N=100005;
db sqr(db x){return x*x;}
struct vec3{ll x,y,z;}p[N];
vec3 operator +(vec3 a,vec3 b){return {a.x+b.x,a.y+b.y,a.z+b.z};}
vec3 operator -(vec3 a,vec3 b){return {a.x-b.x,a.y-b.y,a.z-b.z};}
vec3 operator /(vec3 a,vec3 b){return {a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};}
db abs(vec3 a){return sqrt((lll)a.x*a.x+(lll)a.y*a.y+(lll)a.z*a.z);}
int bcj[N];
int ask(int x){return bcj[x]==x?x:bcj[x]=ask(bcj[x]);}
struct vec3db
{
    db x,y,z;
    db f(int t){return x*t*t+y*t+z;}
}pol[N];
vec3db operator +(vec3db a,vec3db b){return {a.x+b.x,a.y+b.y,a.z+b.z};}
vec3db operator -(vec3db a,vec3db b){return {a.x-b.x,a.y-b.y,a.z-b.z};}
int n,m,q,tofp[N];
map<pii,int> ma;
struct eve{int t,opt,x,y; vec3db p;}e[N*10];
db ans[N];
int lene;
void checkedge(int x,int y,int id)
{
    if(ma.count({x,y}))e[++lene]={(int)max(p[x].z,p[y].z)-1,2,ma[{x,y}],id,0,0,0};
    else ma[{x,y}]=ma[{y,x}]=id;
}
int main()
{
    scanf("%d",&n);
    For(i,1,n)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        p[i]={x,y,z};
    }
    scanf("%d",&m);
    For(i,1,m)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        tofp[x]=i; tofp[y]=i; tofp[z]=i;
        checkedge(x,y,i);
        checkedge(y,z,i);
        checkedge(z,x,i);
        db s=abs((p[x]-p[y])/(p[x]-p[z]))/2;
        int a[3]={p[x].z,p[y].z,p[z].z};
        sort(a,a+3);
        if(a[0]==a[2])e[++lene]={a[0],1,i,0,0,0,s};
        else if(a[0]==a[1])
        {
            s/=sqr(a[2]-a[0]);
            e[++lene]={a[2],1,i,0,s,-2*a[2]*s,sqr(a[2])*s};
            e[++lene]={a[0],1,i,0,-s,2*a[2]*s,(sqr(a[2]-a[0])-sqr(a[2]))*s};
        }
        else if(a[1]==a[2])
        {
            s/=sqr(a[2]-a[0]);
            e[++lene]={a[2],1,i,0,-s,2*a[0]*s,(sqr(a[2]-a[0])-sqr(a[0]))*s};
            e[++lene]={a[0],1,i,0,s,-2*a[0]*s,sqr(a[0])*s};
        }
        else
        {
            db s1=s/(a[2]-a[0])/(a[2]-a[1]);
            e[++lene]={a[2],1,i,0,s1,-2*a[2]*s1,sqr(a[2])*s1};
            e[++lene]={a[1],1,i,0,-s1,2*a[2]*s1,(sqr(a[2]-a[1])-sqr(a[2]))*s1};
            db s2=s/(a[2]-a[0])/(a[1]-a[0]);
            e[++lene]={a[1],1,i,0,-s2,2*a[0]*s2,(sqr(a[1]-a[0])-sqr(a[0]))*s2};
            e[++lene]={a[0],1,i,0,s2,-2*a[0]*s2,sqr(a[0])*s2};
        }
    }
    scanf("%d",&q);
    For(i,1,q)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        e[++lene]={x,0,y,i,0,0,0};
    }
    sort(e+1,e+lene+1,[](eve a,eve b){return a.t==b.t?a.opt>b.opt:a.t>b.t;});
    For(i,1,m)bcj[i]=i;
    For(i,1,lene)
    {
        // printf("%d %d %d %d %.2lf %.2lf %.2lf\n",e[i].t,e[i].opt,e[i].x,e[i].y,e[i].p.x,e[i].p.y,e[i].p.z);
        if(e[i].opt==2)
        {
            int x=ask(e[i].x),y=ask(e[i].y);
            if(x!=y)
            {
                bcj[y]=x;
                pol[x]=pol[x]+pol[y];
            }
        }
        else if(e[i].opt==1)
        {
            int x=ask(e[i].x);
            pol[x]=pol[x]+e[i].p;
        }
        else
        {
            int t=e[i].t,x=e[i].x,y=e[i].y;
            int xx=ask(tofp[x]);
            // printf("x=%d,xx=%d,%.2lf %.2lf %.2lf\n",x,xx,pol[xx].x,pol[xx].y,pol[xx].z);
            if(p[x].z<=t)ans[y]=-1;
            else ans[y]=pol[ask(tofp[x])].f(t);
        }
    }
    For(i,1,q)
        if(ans[i]<0)printf("-1\n");
        else printf("%.10lf\n",ans[i]);
}

詳細信息

answer.code: In function ‘double abs(vec3)’:
answer.code:17:27: error: call of overloaded ‘sqrt(__int128)’ is ambiguous
   17 | db abs(vec3 a){return sqrt((lll)a.x*a.x+(lll)a.y*a.y+(lll)a.z*a.z);}
      |                       ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/c++config.h:679,
                 from /usr/include/c++/13/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:33,
                 from answer.code:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:143:1: note: candidate: ‘double sqrt(double)’
  143 | __MATHCALL (sqrt,, (_Mdouble_ __x));
      | ^~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:114:
/usr/include/c++/13/cmath:442:3: note: candidate: ‘constexpr long double std::sqrt(long double)’
  442 |   sqrt(long double __x)
      |   ^~~~
/usr/include/c++/13/cmath:438:3: note: candidate: ‘constexpr float std::sqrt(float)’
  438 |   sqrt(float __x)
      |   ^~~~
answer.code: In function ‘int main()’:
answer.code:56:24: warning: narrowing conversion of ‘p[x].vec3::z’ from ‘long long int’ to ‘int’ [-Wnarrowing]
   56 |         int a[3]={p[x].z,p[y].z,p[z].z};
      |                   ~~~~~^
answer.code:56:31: warning: narrowing conversion of ‘p[y].vec3::z’ from ‘long long int’ to ‘int’ [-Wnarrowing]
   56 |         int a[3]={p[x].z,p[y].z,p[z].z};
      |                          ~~~~~^
answer.code:56:38: warning: narrowing conversion of ‘p[z].vec3::z’ from ‘long long int’ to ‘int’ [-Wnarrowing]
   56 |         int a[3]={p[x].z,p[y].z,p[z].z};
      |                                 ~~~~~^
answer.code:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
answer.code:43:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   43 |         scanf("%d%d%d",&x,&y,&z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:46:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |     scanf("%d",&m);
      |     ~~~~~^~~~~~~~~
answer.code:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   50 |         scanf("%d%d%d",&x,&y,&z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code:81:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   81 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
answer.code:85:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   85 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~