QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#386242 | #5809. Min Perimeter | AFewSuns | 0 | 3990ms | 35224kb | C++17 | 2.4kb | 2024-04-11 14:26:25 | 2024-04-11 14:26:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define ll long long
#define bl bool
ll my_pow(ll a,ll b,ll mod){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res=(res*a)%mod;
a=(a*a)%mod;
b>>=1;
}
return res;
}
ll qpow(ll a,ll b){
ll res=1;
if(!b) return 1;
while(b){
if(b&1) res*=a;
a*=a;
b>>=1;
}
return res;
}
#define db double
#define pf printf
#define pc putchar
#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
#define go(u) for(ll i=head[u];i;i=e[i].nxt)
#define enter pc('\n')
#define space pc(' ')
#define fir first
#define sec second
#define MP make_pair
#define il inline
#define inf 8e18
#define random(x) rand()*rand()%(x)
#define inv(a,mod) my_pow((a),(mod-2),(mod))
il ll read(){
ll sum=0,f=1;
char ch=0;
while(!isdigit(ch)){
if(ch=='-') f=-1;
ch=getchar();
}
while(isdigit(ch)){
sum=sum*10+(ch^48);
ch=getchar();
}
return sum*f;
}
il void write(ll x){
if(x<0){
x=-x;
pc('-');
}
if(x>9) write(x/10);
pc(x%10+'0');
}
il void writeln(ll x){
write(x);
enter;
}
il void writesp(ll x){
write(x);
space;
}
}
using namespace my_std;
ll t,n;
db ans=inf;
struct node{
ll x,y;
}a[1000010],b[1000010];
il bl cmp(node x,node y){
return x.x<y.x;
}
il db dis(node x,node y){
return sqrt(1.0*(x.x-y.x)*(x.x-y.x)+1.0*(x.y-y.y)*(x.y-y.y));
}
void solve(ll l,ll r){
if(l==r) return;
ll mid=(l+r)>>1,lim=a[mid].x;
solve(l,mid);
solve(mid+1,r);
ll pos1=l,pos2=mid+1,pos=l;
while(pos1<=mid&&pos2<=r){
if(a[pos1].y<=a[pos2].y) b[pos]=a[pos1++];
else b[pos]=a[pos2++];
pos++;
}
fr(i,pos1,mid) b[pos++]=a[i];
fr(i,pos2,r) b[pos++]=a[i];
fr(i,l,r) a[i]=b[i];
pos=0;
fr(i,l,r) if(2.0*abs(a[i].x-lim)<=ans) b[++pos]=a[i];
fr(i,1,pos-2){
fr(j,i+1,pos-1){
if(2.0*(b[j].y-b[i].y)>ans) break;
fr(k,j+1,pos){
if(2.0*(b[k].y-b[i].y)>ans) break;
ans=min(ans,dis(b[i],b[j])+dis(b[j],b[k])+dis(b[k],b[i]));
}
}
}
}
int main(){
// freopen("triangle.in","r",stdin);
// freopen("triangle.out","w",stdout);
t=read();
fr(_,1,t){
ans=inf;
n=read();
fr(i,1,n){
a[i].x=read();
a[i].y=read();
}
sort(a+1,a+n+1,cmp);
solve(1,n);
pf("Case #%lld: %.6lf",_,ans);
}
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 26ms
memory: 6184kb
input:
15 3 2 6 7 0 3 0 3 713 269 371 79 455 421 3 91983245 637281504 756917015 312173515 869576338 436726680 10000 14761642 78236002 9047458 47951098 5238002 27761162 476182 2523742 1428546 7571226 26190010 138805810 21904372 116092132 18094916 95902196 43332562 229660522 55237112 292754072 52380020 27761...
output:
Case #1: 17.893012Case #2: 1042.844835Case #3: 1711142102.791327Case #4: 90912.296374Case #5: 3.414214Case #6: 26.153830Case #7: 1701.012681Case #8: 2865438.191994Case #9: 2020088.337226Case #10: 1792106.037292Case #11: 2019352.542910Case #12: 2530195.728018Case #13: 930517.779631Case #14: 1740324.6...
result:
wrong output format Expected double, but "17.893012Case" found (test case 1)
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 3990ms
memory: 35224kb
input:
15 3 501691275 344354353 167768963 536043860 249445040 557426549 4 1000000000 0 0 0 1000000000 1000000000 0 1000000000 1000000 138925776 669369648 61257680 295150640 170762328 822763944 55483472 267329456 97736936 470914328 84041848 404928904 18463588 88960924 124429360 599523280 95066048 458045504 ...
output:
Case #1: 799653579.133090Case #2: 3414213562.373095Case #3: 866.071591Case #4: 62459.895370Case #5: 59141.918359Case #6: 898195.090968Case #7: 1707085.769987Case #8: 1686.226798Case #9: 1686.603546Case #10: 6806.665584Case #11: 1907363.078325Case #12: 1798829.537861Case #13: 2000000.481954Case #14: ...
result:
wrong output format Expected double, but "799653579.133090Case" found (test case 1)