QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#187429#1. I/O Testwind_whisperCompile Error//C++143.5kb2023-09-24 17:14:432023-09-24 17:14:44

Judging History

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

  • [2023-09-24 17:14:44]
  • 评测
  • [2023-09-24 17:14:43]
  • 提交

config.txt


input_test

#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
#define MN 1000010
#define MM 4000010
int X[1010],Y[1010];double di[1010][1010];
double dis(int a,int b)
{
    return sqrt(1ll*a*a+1ll*b*b);
}
struct lin
{
    int x,y,i;
    void sw(){int t=x;x=y;y=t;}
}sz[102];
bool operator<(const lin&a,const lin&b)
{
    return a.x<b.x;
} 
int cal(int n)
{
    if(n==1)return 1;
    int a=n/2,b=n-a;
    return 2*(cal(a)+cal(b))+a*b;
}
int fr[MN],ne[MM],v[MM],bs=0,N;double w[MM];
void addb(int a,int b,double c)
{
    printf("(%d %d %.2lf)\n",a,b,c);
    v[bs]=b;
    w[bs]=c;
    ne[bs]=fr[a];
    fr[a]=bs++;
}
int wz[MN];vector<pair<int,int> > v3,v4;
void dfs(int l,int r,vector<pair<int,int> >&v1,vector<pair<int,int> >&v2,vector<int>&nd)
{
    if(l==r)
    {
        int i=sz[l].i;fr[++N]=-1;
        v1.push_back(make_pair(i,N));
        v2.push_back(make_pair(i,N));
        nd.push_back(N);return;
    }
    sort(sz+l,sz+r+1);int m=(l+r+1)>>1;
    for(int i=l;i<=r;i++)sz[i].sw();
    vector<pair<int,int> > a,b,c,d;
    vector<int> nl,nr;
    dfs(l,m-1,a,b,nl);dfs(m,r,c,d,nr);
    int s=nl.size();
    for(int i=1;i<=s;i++)fr[N+s]=-1,wz[nl[i-1]]=i;
    for(int i=1;i<=s;i++)
    {
        int u=nl[i-1];
        for(int j=fr[u];j!=-1;j=ne[j])
            addb(N+wz[v[j]],N+i,w[j]);
    }
    for(auto t:a)v1.push_back(t);
    for(auto t:b)v1.push_back(make_pair(t.first,N+wz[t.second]));
    v3.clear();
    for(auto t:b)v3.push_back(t);
    for(auto t:a)v3.push_back(make_pair(t.first,N+wz[t.second]));
    for(int t:nl)nd.push_back(t);
    for(int i=1;i<=s;i++)nd.push_back(N+i);
    N+=s;s=nr.size();
    for(int i=1;i<=s;i++)fr[N+s]=-1,wz[nr[i-1]]=i;
    for(int i=1;i<=s;i++)
    {
        int u=nr[i-1];
        for(int j=fr[u];j!=-1;j=ne[j])
            addb(N+wz[v[j]],N+i,w[j]);
    }
    for(auto t:d)v2.push_back(t);
    for(auto t:c)v2.push_back(make_pair(t.first,N+wz[t.second]));
    v4.clear();
    for(auto t:c)v4.push_back(t);
    for(auto t:d)v4.push_back(make_pair(t.first,N+wz[t.second]));
    for(int t:nr)nd.push_back(t);
    for(int i=1;i<=s;i++)nd.push_back(N+i);
    N+=s;
    int s1=v1.size(),s2=v2.size();
    for(int i=1;i<=s1+s2;i++)fr[N+i]=-1;
    for(int i=1;i<=s1;i++)
        addb(v3[i-1].second,N+i,0);
    for(int i=1;i<=s2;i++)
        addb(N+s1+i,v4[i-1].second,0);
    for(int i=1;i<=s1;i++)
    {
        for(int j=1;j<=s2;j++)
        {
            auto tl=v3[i-1],tr=v4[j-1];
            double c=di[tl.first][tr.first];
            addb(N+i,N+s1+j,c);
        }
    }
    for(int i=1;i<=s1+s2;i++)nd.push_back(N+i);
    N+=s1+s2;
}
bool bk[MN];double jl[MN];int S,T;
double dfs(int u)
{
    if(u==T)return 0;
    if(bk[u])return jl[u];
    bk[u]=1;double mi=1e10;
    for(int i=fr[u];i!=-1;i=ne[i])
    {
        double t=w[i]+dfs(v[i]);
        if(t<mi)mi=t;
    }
    return jl[u]=mi;
}
int main()
{
    //printf("%d",cal(1000));
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&X[i],&Y[i]);
        sz[i].x=X[i];sz[i].y=Y[i];sz[i].i=i;
    }
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            di[i][j]=dis(X[i]-X[j],Y[i]-Y[j]);
    vector<pair<int,int> >v1,v2;vector<int> nd;
    dfs(0,n-1,v1,v2,nd);
    S=N+1;T=N+2;fr[S]=fr[T]=-1;N+=2;
    for(auto t:v1)addb(S,t.second,0);
    for(auto t:v2)addb(t.second,T,0);
    double ans=dfs(S);
    printf("%.10lf",ans);
    return 0;
}

output_test


詳細信息

Invalid Configuration File: failed to read Nin and Nout