QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386342#5809. Min Perimeterqwqer233Compile Error//C++141.6kb2024-04-11 15:39:262024-04-11 15:39:26

Judging History

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

  • [2024-04-11 15:39:26]
  • 评测
  • [2024-04-11 15:39:26]
  • 提交

answer

#pragma GCC optimize("Ofast","unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include<bits/stdc++.h>
#define ll long long
#define ld double
#define fi first
#define se second
using namespace std;
const ll N=1e6+5,INF=1.5e9;
const ld pi=acos(-1.0l);
ll n;ld x[N],y[N];vector<pair<ld,ld>> v;
bool cmp(pair<ld,ld> u,pair<ld,ld> v){return u.fi*u.se<v.fi*v.se;}
const int D=45;
ld d[N][D+4];
ld sq(ld x){return x*x;}
int main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int T;cin>>T;for(int _=1;_<=T;_++){
		ll i;
		cin>>n;v.clear();
		bool b1=1;ll S=0;
		for(i=1;i<=n;i++){
			ll xx,yy;
			cin>>xx>>yy;
			x[i]=xx,y[i]=yy;
			b1&=(yy==0),S^=xx^yy;
		}
		if(b1){
			sort(x+1,x+n+1);
			ld ans=1e18;
			for(i=3;i<=n;i++) ans=min(ans,2*(x[i]-x[i-2]));
			cout<<fixed<<setprecision(15)<<ans<<'\n';
			return 0;
		}srand(19260817);
		ld t=rand()*pi*2/RAND_MAX;
		for(i=1;i<=n;i++){
			x[i]+=0.5,y[i]+=0.5;
			ld g=atan2(y[i],x[i]);
			x[i]=x[i]*cos(t+g)/cos(g);
			y[i]=y[i]*sin(t+g)/sin(g);
		}
		for(i=1;i<=n;i++){
			x[i]+=INF,y[i]+=INF;
			v.push_back({x[i],y[i]});
		}
		sort(v.begin(),v.end(),cmp);for(i=1;i<=n;i++) x[i]=v[i-1].first,y[i]=v[i-1].second;
		ld ans=1e18;
		for(i=1;i<=n;i++){
			for(int j=i+1;j<=min(n,i+D+1);j++){
				d[i][j-i]=sqrt(sq(x[i]-x[j])+sq(y[i]-y[j]));
			}
		}
		for(i=1;i<=n;i++){
			for(int j=i+1,_=min(n,i+D);j<=_;j++){
				for(int k=j+1,__=min(n,i+D);k<=__;k++){
					ans=min(ans,d[i][j-i]+d[j][k-j]+d[i][k-i]);
				}
			}
		}
		cout<<"Case #"<<_<<": "<<fixed<<setprecision(15)<<ans<<'\n';
	}
	return 0;
}

詳細信息

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:3:
/usr/include/c++/13/bits/allocator.h: In destructor ‘std::_Vector_base<std::pair<double, double>, std::allocator<std::pair<double, double> > >::_Vector_impl::~_Vector_impl()’:
/usr/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to ‘always_inline’ ‘std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::pair<double, double>]’: target specific option mismatch
  184 |       ~allocator() _GLIBCXX_NOTHROW { }
      |       ^
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/queue:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157:
/usr/include/c++/13/bits/stl_vector.h:133:14: note: called from here
  133 |       struct _Vector_impl
      |              ^~~~~~~~~~~~