幾何コンテスト2013

Submission #3468616

Source codeソースコード

#include<bits/stdc++.h>
#define MAXM 30000010
#define MAXN 51000
#define INF 0x3f3f3f3f
using namespace std;
struct int_Edge
{
    int u,v;
    int w;
    double cost;
    int next;
}Edge[MAXM];
int dis[MAXN],head[MAXN],pre[MAXN],cnt_Edge=1,Maxf_S,Maxf_T;
inline void Insert_Edge(int u,int v,int w,double cost)
{
    ++cnt_Edge;Edge[cnt_Edge].u=u;Edge[cnt_Edge].v=v;Edge[cnt_Edge].w=w;Edge[cnt_Edge].cost= cost;Edge[cnt_Edge].next=head[u];head[u]=cnt_Edge;
    ++cnt_Edge;Edge[cnt_Edge].u=v;Edge[cnt_Edge].v=u;Edge[cnt_Edge].w=0;Edge[cnt_Edge].cost=-cost;Edge[cnt_Edge].next=head[v];head[v]=cnt_Edge;
}
bool vis[MAXN];
double h[MAXN];
inline bool MCMFSPFA()
{
    static int v;
    for(int i=1;i<MAXN;i++)
        h[i]=1e9+7;
    memset(pre,-1,sizeof(pre));
    h[Maxf_S]=0;
    queue<int>q;
    q.push(Maxf_S);
    while(!q.empty())
    {
        int u=q.front();q.pop();
        vis[u]=false;
        for(register int i=head[u];i;i=Edge[i].next)
        {
            v=Edge[i].v;
            if((h[v]>h[u]+Edge[i].cost)&&Edge[i].w>0)
            {
                h[v]=h[u]+Edge[i].cost;
                pre[v]=i;
                if(!vis[v])
                {
                    vis[v]=true;
                    q.push(v);
                }
            }
        }
    }
    return pre[Maxf_T]!=-1;
}
int MAX_FLOW=0;
double MIN_COST=0.0000000;
inline void MCMF()
{
    while(MCMFSPFA())
    {
        int delt=0x3f3f3f3f;
        double coss=0;
        for(register int i=Maxf_T;i!=Maxf_S;i=Edge[pre[i]].u)
            delt=min(delt,Edge[pre[i]].w);
        for(register int i=Maxf_T;i!=Maxf_S;i=Edge[pre[i]].u)
        {
            Edge[pre[i]].w-=delt;
            Edge[pre[i]^1].w+=delt;
            coss+=Edge[pre[i]].cost;
        }

        MAX_FLOW+=delt;
        MIN_COST+=(coss*delt);
    }
}
double x[MAXN],y[MAXN];
int main()
{
    int n;
    scanf("%d",&n);
    int SS=n*2+2,TT=n*2+3,TTT=n*3+4;
    for(int i=1;i<=n;i++)scanf("%lf%lf",&x[i],&y[i]);
    for(int i=1;i<=n;i++)
    {
        Insert_Edge(SS,i,1,0.0000000);
        Insert_Edge(i+n,TT,1,0);
        Insert_Edge(i,i+n,1,abs(x[i]));
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j)
                continue;
            Insert_Edge(i,j+n,1,sqrt((x[i]+x[j])*(x[i]+x[j])+(y[i]-y[j])*(y[i]-y[j]))/2);
        }
    }
    Insert_Edge(TT,TTT,n,0.0000000);
    Maxf_S=SS;
    Maxf_T=TTT;
    MCMF();
    printf("%.7f",MIN_COST);
    return 0;
}

Submission

Task問題 B - 玉座の間
User nameユーザ名 luogu_bot2
Created time投稿日時
Language言語 C++ (GCC 5.4.1)
Status状態 AC
Score得点 200
Source lengthソースコード長 2465 Byte
File nameファイル名
Exec time実行時間 51 ms
Memory usageメモリ使用量 3072 KB

Compiler messageコンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:76:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:78:53: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;i++)scanf("%lf%lf",&x[i],&y[i]);
^

Test case

Set

Set name Score得点 / Max score Cases
Subtask1 50 / 50 11_rand00.txt,11_rand01.txt,11_rand02.txt,11_rand03.txt,11_rand04.txt,11_rand05.txt,11_rand06.txt,11_rand07.txt,11_rand08.txt,11_rand09.txt,11_rand10.txt,11_rand11.txt,11_rand12.txt,11_rand13.txt,11_rand14.txt,11_rand15.txt,11_rand16.txt,11_rand17.txt,11_rand18.txt,11_rand19.txt,11_rand20.txt,11_rand21.txt,11_rand22.txt,11_rand23.txt,11_rand24.txt
Subtask2 50 / 50 11_rand00.txt,11_rand01.txt,11_rand02.txt,11_rand03.txt,11_rand04.txt,11_rand05.txt,11_rand06.txt,11_rand07.txt,11_rand08.txt,11_rand09.txt,11_rand10.txt,11_rand11.txt,11_rand12.txt,11_rand13.txt,11_rand14.txt,11_rand15.txt,11_rand16.txt,11_rand17.txt,11_rand18.txt,11_rand19.txt,11_rand20.txt,11_rand21.txt,11_rand22.txt,11_rand23.txt,11_rand24.txt,21_rand00.txt,21_rand01.txt,21_rand02.txt,21_rand03.txt,21_rand04.txt,21_rand05.txt,21_rand06.txt,21_rand07.txt,21_rand08.txt,21_rand09.txt,21_rand10.txt,21_rand11.txt,21_rand12.txt,21_rand13.txt,21_rand14.txt,21_rand15.txt,21_rand16.txt,21_rand17.txt,21_rand18.txt,21_rand19.txt,21_rand20.txt,21_rand21.txt,21_rand22.txt,21_rand23.txt,21_rand24.txt
Subtask3 50 / 50 11_rand00.txt,11_rand01.txt,11_rand02.txt,11_rand03.txt,11_rand04.txt,11_rand05.txt,11_rand06.txt,11_rand07.txt,11_rand08.txt,11_rand09.txt,11_rand10.txt,11_rand11.txt,11_rand12.txt,11_rand13.txt,11_rand14.txt,11_rand15.txt,11_rand16.txt,11_rand17.txt,11_rand18.txt,11_rand19.txt,11_rand20.txt,11_rand21.txt,11_rand22.txt,11_rand23.txt,11_rand24.txt,21_rand00.txt,21_rand01.txt,21_rand02.txt,21_rand03.txt,21_rand04.txt,21_rand05.txt,21_rand06.txt,21_rand07.txt,21_rand08.txt,21_rand09.txt,21_rand10.txt,21_rand11.txt,21_rand12.txt,21_rand13.txt,21_rand14.txt,21_rand15.txt,21_rand16.txt,21_rand17.txt,21_rand18.txt,21_rand19.txt,21_rand20.txt,21_rand21.txt,21_rand22.txt,21_rand23.txt,21_rand24.txt,31_rand00.txt,31_rand01.txt,31_rand02.txt,31_rand03.txt,31_rand04.txt,31_rand05.txt,31_rand06.txt,31_rand07.txt,31_rand08.txt,31_rand09.txt,31_rand10.txt,31_rand11.txt,31_rand12.txt,31_rand13.txt,31_rand14.txt,31_rand15.txt,31_rand16.txt,31_rand17.txt,31_rand18.txt,31_rand19.txt,31_rand20.txt,31_rand21.txt,31_rand22.txt,31_rand23.txt,31_rand24.txt
Subtask4 50 / 50 11_rand00.txt,11_rand01.txt,11_rand02.txt,11_rand03.txt,11_rand04.txt,11_rand05.txt,11_rand06.txt,11_rand07.txt,11_rand08.txt,11_rand09.txt,11_rand10.txt,11_rand11.txt,11_rand12.txt,11_rand13.txt,11_rand14.txt,11_rand15.txt,11_rand16.txt,11_rand17.txt,11_rand18.txt,11_rand19.txt,11_rand20.txt,11_rand21.txt,11_rand22.txt,11_rand23.txt,11_rand24.txt,21_rand00.txt,21_rand01.txt,21_rand02.txt,21_rand03.txt,21_rand04.txt,21_rand05.txt,21_rand06.txt,21_rand07.txt,21_rand08.txt,21_rand09.txt,21_rand10.txt,21_rand11.txt,21_rand12.txt,21_rand13.txt,21_rand14.txt,21_rand15.txt,21_rand16.txt,21_rand17.txt,21_rand18.txt,21_rand19.txt,21_rand20.txt,21_rand21.txt,21_rand22.txt,21_rand23.txt,21_rand24.txt,31_rand00.txt,31_rand01.txt,31_rand02.txt,31_rand03.txt,31_rand04.txt,31_rand05.txt,31_rand06.txt,31_rand07.txt,31_rand08.txt,31_rand09.txt,31_rand10.txt,31_rand11.txt,31_rand12.txt,31_rand13.txt,31_rand14.txt,31_rand15.txt,31_rand16.txt,31_rand17.txt,31_rand18.txt,31_rand19.txt,31_rand20.txt,31_rand21.txt,31_rand22.txt,31_rand23.txt,31_rand24.txt,41_rand00.txt,41_rand01.txt,41_rand02.txt,41_rand03.txt,41_rand04.txt,41_rand05.txt,41_rand06.txt,41_rand07.txt,41_rand08.txt,41_rand09.txt,41_rand10.txt,41_rand11.txt,41_rand12.txt,41_rand13.txt,41_rand14.txt,41_rand15.txt,41_rand16.txt,41_rand17.txt,41_rand18.txt,41_rand19.txt,41_rand20.txt,41_rand21.txt,41_rand22.txt,41_rand23.txt,41_rand24.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
11_rand00.txt AC 2 ms 896 KB
11_rand01.txt AC 2 ms 896 KB
11_rand02.txt AC 1 ms 896 KB
11_rand03.txt AC 1 ms 896 KB
11_rand04.txt AC 1 ms 896 KB
11_rand05.txt AC 1 ms 896 KB
11_rand06.txt AC 1 ms 896 KB
11_rand07.txt AC 1 ms 896 KB
11_rand08.txt AC 1 ms 896 KB
11_rand09.txt AC 1 ms 896 KB
11_rand10.txt AC 1 ms 896 KB
11_rand11.txt AC 1 ms 896 KB
11_rand12.txt AC 1 ms 896 KB
11_rand13.txt AC 2 ms 896 KB
11_rand14.txt AC 1 ms 896 KB
11_rand15.txt AC 1 ms 896 KB
11_rand16.txt AC 2 ms 896 KB
11_rand17.txt AC 1 ms 896 KB
11_rand18.txt AC 1 ms 896 KB
11_rand19.txt AC 1 ms 896 KB
11_rand20.txt AC 1 ms 896 KB
11_rand21.txt AC 1 ms 896 KB
11_rand22.txt AC 1 ms 896 KB
11_rand23.txt AC 1 ms 896 KB
11_rand24.txt AC 1 ms 896 KB
21_rand00.txt AC 1 ms 896 KB
21_rand01.txt AC 1 ms 896 KB
21_rand02.txt AC 2 ms 896 KB
21_rand03.txt AC 1 ms 896 KB
21_rand04.txt AC 2 ms 896 KB
21_rand05.txt AC 2 ms 896 KB
21_rand06.txt AC 1 ms 896 KB
21_rand07.txt AC 1 ms 896 KB
21_rand08.txt AC 2 ms 896 KB
21_rand09.txt AC 2 ms 896 KB
21_rand10.txt AC 1 ms 896 KB
21_rand11.txt AC 1 ms 896 KB
21_rand12.txt AC 1 ms 896 KB
21_rand13.txt AC 1 ms 896 KB
21_rand14.txt AC 2 ms 896 KB
21_rand15.txt AC 2 ms 896 KB
21_rand16.txt AC 1 ms 896 KB
21_rand17.txt AC 2 ms 896 KB
21_rand18.txt AC 2 ms 896 KB
21_rand19.txt AC 1 ms 896 KB
21_rand20.txt AC 2 ms 896 KB
21_rand21.txt AC 1 ms 896 KB
21_rand22.txt AC 1 ms 896 KB
21_rand23.txt AC 1 ms 896 KB
21_rand24.txt AC 2 ms 896 KB
31_rand00.txt AC 2 ms 896 KB
31_rand01.txt AC 2 ms 896 KB
31_rand02.txt AC 2 ms 896 KB
31_rand03.txt AC 2 ms 896 KB
31_rand04.txt AC 2 ms 896 KB
31_rand05.txt AC 2 ms 896 KB
31_rand06.txt AC 2 ms 896 KB
31_rand07.txt AC 2 ms 896 KB
31_rand08.txt AC 1 ms 896 KB
31_rand09.txt AC 2 ms 896 KB
31_rand10.txt AC 2 ms 896 KB
31_rand11.txt AC 2 ms 896 KB
31_rand12.txt AC 2 ms 896 KB
31_rand13.txt AC 2 ms 896 KB
31_rand14.txt AC 2 ms 896 KB
31_rand15.txt AC 2 ms 896 KB
31_rand16.txt AC 2 ms 896 KB
31_rand17.txt AC 2 ms 896 KB
31_rand18.txt AC 2 ms 896 KB
31_rand19.txt AC 2 ms 896 KB
31_rand20.txt AC 2 ms 896 KB
31_rand21.txt AC 2 ms 896 KB
31_rand22.txt AC 2 ms 896 KB
31_rand23.txt AC 2 ms 896 KB
31_rand24.txt AC 2 ms 896 KB
41_rand00.txt AC 3 ms 896 KB
41_rand01.txt AC 1 ms 896 KB
41_rand02.txt AC 6 ms 1024 KB
41_rand03.txt AC 9 ms 3072 KB
41_rand04.txt AC 12 ms 3072 KB
41_rand05.txt AC 5 ms 1024 KB
41_rand06.txt AC 5 ms 1024 KB
41_rand07.txt AC 20 ms 3072 KB
41_rand08.txt AC 2 ms 896 KB
41_rand09.txt AC 4 ms 1024 KB
41_rand10.txt AC 2 ms 896 KB
41_rand11.txt AC 12 ms 3072 KB
41_rand12.txt AC 21 ms 3072 KB
41_rand13.txt AC 3 ms 896 KB
41_rand14.txt AC 6 ms 1024 KB
41_rand15.txt AC 2 ms 896 KB
41_rand16.txt AC 2 ms 896 KB
41_rand17.txt AC 10 ms 3072 KB
41_rand18.txt AC 51 ms 3072 KB
41_rand19.txt AC 47 ms 3072 KB
41_rand20.txt AC 6 ms 1024 KB
41_rand21.txt AC 2 ms 896 KB
41_rand22.txt AC 4 ms 1024 KB
41_rand23.txt AC 23 ms 3072 KB
41_rand24.txt AC 10 ms 3072 KB