QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#312943 | #5264. Wyprzedzanie | tuxuanming2024 | Compile Error | / | / | C++14 | 1.7kb | 2024-01-24 15:01:01 | 2024-01-24 15:01:01 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef LOCAL
#include "txm/debug.h"
#endif
using namespace std;
#define ld __float128
typedef long long ll;
const int N=100005;
const ld eps=1e-12;
int n,D,d[N],x[N],nxt[N],p[N][17],s[N],ans;
ld V,v[N],t[N],pos[N];
bool iseq(ld x,ld y) {return fabs(x-y)<eps;}
ld ask(int a,ld tt)
{
if(tt<t[a]) return x[a]+v[a]*tt;
int y=a;
for(int i=16;i>=0;i--)
if(p[y][i]&&(tt>t[p[y][i]]||iseq(t[p[y][i]],tt))) y=p[y][i];
tt-=t[y];
return pos[y]+v[p[y][0]]*tt-(s[y]-s[a]);
}
signed main()
{
int w,m;
scanf("%d %d %d %d",&n,&D,&w,&m),V=(ld)w/m;
for(int i=1;i<=n;i++)
{
scanf("%d %d %d %d",x+i,d+i,&w,&m);
v[i]=(ld)w/m,s[i]=s[i-1]+d[i];
}
nxt[n]=n+1,t[n]=1e19,pos[n]=x[n];
for(int i=n-1;i>=1;i--)
{
nxt[i]=i+1;
while(nxt[i]<=n&&(v[i]<v[nxt[i]]||iseq(v[i],v[nxt[i]]))) nxt[i]=nxt[nxt[i]];
if(nxt[i]>n) {t[i]=1e19,pos[i]=x[i]; continue;}
int to=nxt[i];
ld tt=(x[to]-x[i]-(s[to]-s[i]))/(v[i]-v[to]);
if(tt>t[to]||iseq(tt,t[to]))
{
for(int j=16;j>=0;j--)
{
int k=p[nxt[i]][j];
if(!k) continue;
tt=(x[k]-x[i]-(s[k]-s[i]))/(v[i]-v[k]);
if(tt>t[k]||iseq(tt,t[k])) to=k;
}
to=p[to][0];
}
p[i][0]=to;
t[i]=(x[to]-x[i]-(s[to]-s[i]))/(v[i]-v[to]);
pos[i]=x[i]+v[i]*t[i];
for(int j=1;1<<j<=n;j++) p[i][j]=p[p[i][j-1]][j-1];
}
for(int i=1;i<=n;i++)
{
ld tt=0;
int j=i;
if(V*t[i]>x[i]-d[i]) tt=(x[i]-d[i])/(V-v[i]);
else
{
for(int k=16;k>=0;k--)
{
int fa=p[j][k];
if(!fa||t[fa]==1e19) continue;
if(V*t[fa]<pos[fa]-(s[fa]-s[i])) j=fa;
}
j=p[j][0];
tt=(x[j]-(s[j]-s[i-1]))/(V-v[j]);
}
ld L=ask(i,tt)-d[i]-ask(i-1,tt);
if(i==1||L>D||iseq(L,D)) ans++;
}
printf("%d",ans);
return 0;
}
Details
answer.code: In function ‘bool iseq(__float128, __float128)’: answer.code:12:34: error: call of overloaded ‘fabs(__float128)’ is ambiguous 12 | bool iseq(ld x,ld y) {return fabs(x-y)<eps;} | ~~~~^~~~~ 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:162:1: note: candidate: ‘double fabs(double)’ 162 | __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__)); | ^~~~~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:114: /usr/include/c++/13/cmath:238:3: note: candidate: ‘constexpr long double std::fabs(long double)’ 238 | fabs(long double __x) | ^~~~ /usr/include/c++/13/cmath:234:3: note: candidate: ‘constexpr float std::fabs(float)’ 234 | fabs(float __x) | ^~~~ answer.code: In function ‘int main()’: answer.code:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d %d %d %d",&n,&D,&w,&m),V=(ld)w/m; | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:28:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%d %d %d %d",x+i,d+i,&w,&m); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~