QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#648607#4886. Best SunN_z_Compile Error//C++237.1kb2024-10-17 19:39:392024-10-17 19:39:39

Judging History

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

  • [2024-10-17 19:39:39]
  • 评测
  • [2024-10-17 19:39:39]
  • 提交

answer

#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt")
#if defined(LOCAL) or not defined(LUOGU)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,unroll-loops")
#endif
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
#define Setprecision 10
#define between ' '
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(T x){for(auto &y:x)*this<<y<<between;*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(T c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(std::string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl

const double pi=acos(-1),eps=1e-8,inf=9e18;
int n,id[301],id2[301];
bool ok[301][301];
double dis2[301][301],dp[301],dis[301][301],the[301][301];
pair<double,double>a[301];
vector<pair<int,int>>lne;
pair<double,double>operator+(pair<double,double>a,pair<double,double>b){a.first+=b.first,a.second+=b.second;return a;}
pair<double,double>operator-(pair<double,double>a,pair<double,double>b){a.first-=b.first,a.second-=b.second;return a;}
pair<double,double>operator*(pair<double,double>a,double b){a.first*=b,a.second*=b;return a;}
double getth(pair<double,double>a){return atan2(a.second,a.first);}
double getth2(double th){if(th<0)th+=pi*2;return th;}
double getth3(double th){if(th<-pi/2)th+=pi*2;return th;}
double getdis(pair<double,double>a,pair<double,double>b){return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));}
double cross(pair<double,double>a,pair<double,double>b){return a.first*b.second-a.second*b.first;}
bool check(int p,double mi){
	double res=-inf;
	for(int x=p+1;x<=n;x++)dp[x]=-inf;
	dp[p]=0;
	for(auto q:lne){
		int u=q.first,v=q.second;
		if(u<p||v<p||(!ok[u][v]))continue;
		if(v==p)res=max(res,dp[u]-mi*dis2[u][v]);
		else dp[v]=max(dp[v],dp[u]+cross(a[v]-a[u],a[p]-a[u])/2-mi*dis2[u][v]);
	}
	for(int x=1;x<=n;x++)res-=mi*dis[p][x];
//	cerr<<p<<','<<mi<<','<<res<<endl;
	return res>=0;
}
mt19937 mt(time(0));
void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i].first>>a[i].second;
	sort(a+1,a+n+1,[&](pair<double,double>a,pair<double,double>b){return make_pair(a.second,a.first)<make_pair(b.second,b.first);});
	for(int x=1;x<=n;x++)
	for(int y=1;y<=n;y++)
	dis[x][y]=getdis(a[x],a[y]),the[x][y]=getth(a[y]-a[x]);
	lne.clear();
	for(int x=1;x<=n;x++)
	for(int y=1;y<=n;y++)
	if(x!=y)
	{
		lne.emplace_back(x,y);
		dis2[x][y]=dis[x][y];
		pair<double,double>u=a[x],w=a[y],v=(u+w)*0.5,tmp={w.second-u.second,u.first-w.first};
		double tmpth=getth3(getth(tmp));
		for(int z=1;z<=n;z++){
			if(getth3(the[x][z])<tmpth)dis2[x][y]+=dis[x][z];
			if(getth3(the[y][z])<=tmpth)dis2[x][y]-=dis[y][z];
			if(z==x||z==y)continue;
			if(cross(a[z]-u,w-u)>0)
			if(cross(tmp,a[z]-u)>=0&&cross(a[z]-v,tmp)>=0)dis2[x][y]+=dis[x][z];
			else if(cross(tmp,a[z]-v)>0&&cross(a[z]-w,tmp)>=0)dis2[x][y]+=dis[y][z];
		}
	}
	sort(lne.begin(),lne.end(),[&](pair<int,int>x,pair<int,int>y){return getth2(the[x.first][x.second])<getth2(the[y.first][y.second]);});
	double ans=0;
	for(int x=1;x<=n;x++)id2[x]=x;
	shuffle(id2+1,id2+n+1,mt);
	for(int _=1;_<=n;_++)
	{
		int x=id2[_];
		for(int y=1;y<=n;y++)
		for(int z=1;z<=n;z++)
		ok[y][z]=0;
		int cnt=n-x;
		for(int y=x+1;y<=n;y++)
		id[y-x]=y;
		sort(id+1,id+cnt+1,[&](int a,int b){return the[x][a]<the[x][b];});
		for(int y=1;y<=cnt;y++)
		{
			ok[x][id[y]]=ok[id[y]][x]=1;
			pair<double,double>tmp={0,0};
			for(int z=y+1;z<=cnt;z++)
			if(cross(tmp,a[id[z]]-a[id[y]])>=0)ok[id[y]][id[z]]=ok[id[z]][id[y]]=1,tmp=a[id[z]]-a[id[y]];
		}
		if(!check(x,ans))continue;
		double l=ans,r=1e6;
		while(r-l>=eps){
			double mi=(l+r)/2;
			if(check(x,mi))ans=mi,l=mi;
			else r=mi;
		}
	}
	cout<<ans<<endl;
}
main()
{
	int T;
	cin>>T;
	while(T--)solve();
}

详细

answer.code:110:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
  110 | main()
      | ^~~~
In file included from /usr/include/c++/13/string:43,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from answer.code:6:
/usr/include/c++/13/bits/allocator.h: In destructor ‘constexpr std::_Vector_base<std::pair<int, int>, std::allocator<std::pair<int, int> > >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘constexpr std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::pair<int, int>]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~