提出 #65180431


ソースコード 拡げる

#include<bits/stdc++.h>
using namespace std;
typedef long double db;
const int N=310;

int n;
db sx[N],sy[N],tx[N],ty[N];
db dis[N][N];
db pow(db w) {return w*w;}
vector<int>ver[N];
bool vis[N];
int match[N];

int find(int u) {
    for(int v:ver[u]) {
        if(!vis[v]) {
            vis[v]=1;
            if(!match[v]||find(match[v])) {
                match[v]=u; 
                return 1;
            }
        }
    }
    return 0;
}

bool check(db mid) {
    for(int i=1;i<=n;i++) ver[i].clear();
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++)
            if(dis[i][j]<mid) ver[i].push_back(j);
    }
    for(int i=1;i<=n;i++) match[i]=0;
    int ans=0;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) vis[j]=0;
        ans+=find(i);
    }
    return ans==n;
}


int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%Lf%Lf",&sx[i],&sy[i]);
    for(int i=1;i<=n;i++) scanf("%Lf%Lf",&tx[i],&ty[i]);
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=n;j++) dis[i][j]=sqrt(pow(sx[i]-tx[j])+pow(sy[i]-ty[j]));
    }
    //printf("%d\n",check(2.01));
    db l=0,r=1e20,mid;
    for(int _=1;_<=200;_++) {
        mid=(l+r)/2.0;
        if(check(mid)) r=mid;
        else l=mid;
    }
    printf("%.8Lf\n",l);
}

提出情報

提出日時
問題 G - Push Simultaneously
ユーザ cjh_hhz
言語 C++ 20 (gcc 12.2)
得点 575
コード長 1303 Byte
結果 AC
実行時間 723 ms
メモリ 5968 KiB

コンパイルエラー

Main.cpp: In function ‘int main()’:
Main.cpp:44:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   44 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
Main.cpp:45:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |     for(int i=1;i<=n;i++) scanf("%Lf%Lf",&sx[i],&sy[i]);
      |                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:46:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |     for(int i=1;i<=n;i++) scanf("%Lf%Lf",&tx[i],&ty[i]);
      |                           ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 575 / 575
結果
AC × 3
AC × 42
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 02_handmade_32.txt, 02_handmade_33.txt, 02_handmade_34.txt, 02_handmade_35.txt, 02_handmade_36.txt, 02_handmade_37.txt, 02_handmade_38.txt, 02_handmade_39.txt, 02_handmade_40.txt, 02_handmade_41.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 1 ms 3832 KiB
00_sample_01.txt AC 1 ms 3832 KiB
00_sample_02.txt AC 1 ms 3816 KiB
01_random_03.txt AC 159 ms 5760 KiB
01_random_04.txt AC 474 ms 5904 KiB
01_random_05.txt AC 527 ms 5908 KiB
01_random_06.txt AC 369 ms 5860 KiB
01_random_07.txt AC 362 ms 5808 KiB
01_random_08.txt AC 419 ms 5816 KiB
01_random_09.txt AC 320 ms 5968 KiB
01_random_10.txt AC 203 ms 5916 KiB
01_random_11.txt AC 330 ms 5740 KiB
01_random_12.txt AC 498 ms 5864 KiB
01_random_13.txt AC 511 ms 5864 KiB
01_random_14.txt AC 478 ms 5868 KiB
01_random_15.txt AC 590 ms 5844 KiB
01_random_16.txt AC 399 ms 5908 KiB
01_random_17.txt AC 250 ms 5904 KiB
01_random_18.txt AC 277 ms 5860 KiB
01_random_19.txt AC 227 ms 5808 KiB
01_random_20.txt AC 90 ms 5760 KiB
01_random_21.txt AC 87 ms 5836 KiB
01_random_22.txt AC 87 ms 5740 KiB
01_random_23.txt AC 227 ms 5816 KiB
01_random_24.txt AC 94 ms 5892 KiB
01_random_25.txt AC 89 ms 5848 KiB
01_random_26.txt AC 91 ms 5968 KiB
01_random_27.txt AC 440 ms 5908 KiB
01_random_28.txt AC 432 ms 5740 KiB
01_random_29.txt AC 297 ms 5896 KiB
01_random_30.txt AC 300 ms 5896 KiB
01_random_31.txt AC 304 ms 5848 KiB
02_handmade_32.txt AC 719 ms 5804 KiB
02_handmade_33.txt AC 713 ms 5864 KiB
02_handmade_34.txt AC 630 ms 5744 KiB
02_handmade_35.txt AC 713 ms 5744 KiB
02_handmade_36.txt AC 710 ms 5896 KiB
02_handmade_37.txt AC 716 ms 5816 KiB
02_handmade_38.txt AC 657 ms 5920 KiB
02_handmade_39.txt AC 723 ms 5944 KiB
02_handmade_40.txt AC 710 ms 5964 KiB
02_handmade_41.txt AC 710 ms 5844 KiB