QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#105009#5170. 加速度haorenCompile Error//C++141.5kb2023-05-12 20:20:202023-05-12 20:20:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-12 20:20:22]
  • 评测
  • [2023-05-12 20:20:20]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	int aa=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')aa=(aa<<3)+(aa<<1)+ch-'0',ch=getchar();
	return aa*f;
}
const int M=5e3+10;
int n,a;
int s[M],l[M],r[M];
double f[M],ans=1e18;
main(){
	n=read();a=read();for(int i=1;i<=n+1;i++) s[i]=read();for(int i=1;i<=n+1;i++) l[i]=read(),r[i]=read();r[1]=0;
	for(int i=1;i<=n;i++){
		double l1=0,l2=0,r1=1e18,r2=f[i];
		//路径需要等待时间/提供等待时间 
		//路径速度限制 
		for(int j=i+1;j<=n;j++){
			//无初速度 
			if(r[j]<r[i]) break;double t=sqrt(2.0*(s[j]-s[i])*1.0/(1.0*a)),wt=r[j]-r[i]-t;//等待时间
			if(wt>=l1&&wt<=r1) f[j]=max(f[j],t*1.0*a);if(l[j]>r[i]) l1=max(l1,l[j]-r[i]-t);r1=min(r1,wt);
		    //有初速度
			double v0=(s[j]-s[i])*1.0/(1.0*(r[j]-r[i]))-0.5*a*((r[j]-r[i])*1.0);
			if(v0>=l2&&v0<=r2) f[j]=max(f[j],sqrt(2.0*a*(1.0*(s[j]-s[i]))+v0*v0)); 
		    if(l[j]>r[i]) r2=min(r2,(s[j]-s[i])*1.0/(1.0*(l[j]-r[i]))-0.5*a*(1.0*(l[j]-r[i])));l2=max(l2,v0);
			if(j==n){
		    	if(l1<=r1&&sqrt(2.0*(s[n+1]-s[i])*1.0/(1.0*a))<=r[n+1]) ans=min(ans,sqrt(2.0*(s[n+1]-s[i])*1.0/(1.0*a))+l1+r[i]);
			    if(l2<=r2){double vmax=sqrt((s[n+1]-s[i])*1.0*a*2.0+r2*r2);
				cout<<(vmax-r2)*1.0/(1.0*a)+r[i]<<'\n';
				ans=min(ans,(vmax-r2)*1.0/(1.0*a)+r[i]);}
			}
		}
	}
	if(ans==1e18) cout<<"kaibai";
	else printf("%0.6lf",max(ans,l[n+1]));
}

Details

answer.code:15:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   15 | main(){
      | ^~~~
answer.code: In function ‘int main()’:
answer.code:38:33: error: no matching function for call to ‘max(double&, long long int&)’
   38 |         else printf("%0.6lf",max(ans,l[n+1]));
      |                              ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: ‘template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)’
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:38:33: note:   deduced conflicting types for parameter ‘const _Tp’ (‘double’ and ‘long long int’)
   38 |         else printf("%0.6lf",max(ans,l[n+1]));
      |                              ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)’
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:38:33: note:   deduced conflicting types for parameter ‘const _Tp’ (‘double’ and ‘long long int’)
   38 |         else printf("%0.6lf",max(ans,l[n+1]));
      |                              ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
answer.code:38:33: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘double’
   38 |         else printf("%0.6lf",max(ans,l[n+1]));
      |                              ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
answer.code:38:33: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘double’
   38 |         else printf("%0.6lf",max(ans,l[n+1]));
      |                              ~~~^~~~~~~~~~~~