QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480988#784. 旋转卡壳ucup-team1004#Compile Error//C++172.0kb2024-07-16 19:59:312024-07-16 19:59:31

Judging History

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

  • [2024-10-16 12:18:36]
  • hack成功,自动添加数据
  • (/hack/1005)
  • [2024-09-24 16:55:39]
  • hack成功,自动添加数据
  • (/hack/888)
  • [2024-07-31 21:52:32]
  • hack成功,自动添加数据
  • (/hack/764)
  • [2024-07-31 21:47:53]
  • hack成功,自动添加数据
  • (/hack/763)
  • [2024-07-16 19:59:31]
  • 评测
  • [2024-07-16 19:59:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
using vec=complex<int>;
const int N=5e5+10;
int n;
vec a[N];
ll dot(const vec &a,const vec &b){
	return 1ll*real(a)*real(b)+1ll*imag(a)*imag(b);
}
ll cross(const vec &a,const vec &b){
	return dot(a,b*vec(0,-1));
}
ll dis2(const vec &a){
	return dot(a,a);
}
double dis(const vec &a){
	return sqrt(dis2(a));
}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<=n;i++){
		scanf("%d%d",&x,&y),a[i]=vec(x,y);
	}
	ll ans=0;
	int x=0;
	auto chk=[&](int i,int y){
		vec cur=a[i]-a[i%n+1];
		int x=y>1?y-1:n,z=y%n+1;
		return cross(a[y]-a[x],cur)>=0&&cross(cur,a[z]-a[y])>0;
	};
	for(int i=1;i<=n;i++)if(chk(1,i))x=i;
	for(int i=1;i<=n;i++){
		for(;!chk(i,x);x=x%n+1);
		ans=max({ans,dis2(a[i]-a[x]),dis2(a[i%n+1]-a[x])});
	}
	printf("%.9Lf\n",sqrtl(ans));
	return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include"debug.h"
#else
#define debug(...) void()
#endif
#define all(x) (x).begin(),(x).end()
template<class T>
auto ary(T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
using ll=long long;
using ull=unsigned long long;
using vec=complex<int>;
const int N=5e5+10;
int n;
vec a[N];
ll dot(const vec &a,const vec &b){
	return 1ll*real(a)*real(b)+1ll*imag(a)*imag(b);
}
ll cross(const vec &a,const vec &b){
	return dot(a,b*vec(0,-1));
}
ll dis2(const vec &a){
	return dot(a,a);
}
double dis(const vec &a){
	return sqrt(dis2(a));
}
int main(){
	scanf("%d",&n);
	for(int i=1,x,y;i<=n;i++){
		scanf("%d%d",&x,&y),a[i]=vec(x,y);
	}
	ll ans=0;
	for(int i=1,j=2;i<=n;i++){
		for(;dis2(a[i]-a[j])<dis2(a[i]-a[j%n+1]);j=j%n+1);
		ans=max(ans,dis2(a[i]-a[j]));
	}
	printf("%.9lf\n",sqrt(ans));
	return 0;
}
#ifdef DEBUG
#include"debug.hpp"
#endif

Details

answer.code:53:7: warning: extra tokens at end of #endif directive [-Wendif-labels]
   53 | #endif#include<bits/stdc++.h>
      |       ^
answer.code:62:6: error: redefinition of ‘template<class T> auto ary(T*, int, int)’
   62 | auto ary(T *a,int l,int r){
      |      ^~~
answer.code:10:6: note: ‘template<class T> auto ary(T*, int, int)’ previously declared here
   10 | auto ary(T *a,int l,int r){
      |      ^~~
answer.code:68:11: error: redefinition of ‘const int N’
   68 | const int N=5e5+10;
      |           ^
answer.code:16:11: note: ‘const int N’ previously defined here
   16 | const int N=5e5+10;
      |           ^
answer.code:69:5: error: redefinition of ‘int n’
   69 | int n;
      |     ^
answer.code:17:5: note: ‘int n’ previously declared here
   17 | int n;
      |     ^
answer.code:70:5: error: redefinition of ‘vec a [500010]’
   70 | vec a[N];
      |     ^
answer.code:18:5: note: ‘vec a [500010]’ previously defined here
   18 | vec a[N];
      |     ^
answer.code:71:4: error: redefinition of ‘ll dot(const vec&, const vec&)’
   71 | ll dot(const vec &a,const vec &b){
      |    ^~~
answer.code:19:4: note: ‘ll dot(const vec&, const vec&)’ previously defined here
   19 | ll dot(const vec &a,const vec &b){
      |    ^~~
answer.code:74:4: error: redefinition of ‘ll cross(const vec&, const vec&)’
   74 | ll cross(const vec &a,const vec &b){
      |    ^~~~~
answer.code:22:4: note: ‘ll cross(const vec&, const vec&)’ previously defined here
   22 | ll cross(const vec &a,const vec &b){
      |    ^~~~~
answer.code:77:4: error: redefinition of ‘ll dis2(const vec&)’
   77 | ll dis2(const vec &a){
      |    ^~~~
answer.code:25:4: note: ‘ll dis2(const vec&)’ previously defined here
   25 | ll dis2(const vec &a){
      |    ^~~~
answer.code:80:8: error: redefinition of ‘double dis(const vec&)’
   80 | double dis(const vec &a){
      |        ^~~
answer.code:28:8: note: ‘double dis(const vec&)’ previously defined here
   28 | double dis(const vec &a){
      |        ^~~
answer.code:83:5: error: redefinition of ‘int main()’
   83 | int main(){
      |     ^~~~
answer.code:31:5: note: ‘int main()’ previously defined here
   31 | int main(){
      |     ^~~~
answer.code: In function ‘int main()’:
answer.code:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code:34:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   34 |                 scanf("%d%d",&x,&y),a[i]=vec(x,y);
      |                 ~~~~~^~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:84:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   84 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code:86:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   86 |                 scanf("%d%d",&x,&y),a[i]=vec(x,y);
      |                 ~~~~~^~~~~~~~~~~~~~