답안 #473884

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
473884 2021-09-16T11:16:32 Z BidoTeima Odašiljači (COCI20_odasiljaci) C++17
14 / 70
1000 ms 20864 KB
/// isA AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
#define tc         \
    int tttttt,subtask;    \
    cin >> tttttt /*>> subtask*/; \
    while (tttttt--)
#define sumrange(l, r, arr) (l == 0 ? arr[r] : arr[r] - arr[l - 1])
#define all(v) v.begin(), v.end()
bool touch(long double x1, long double y1, long double x2,
           long double y2, long double r1, long double r2)
{
    long double distSq = (x1 - x2) * (x1 - x2) +
                 (y1 - y2) * (y1 - y2);
    long double radSumSq = (r1 + r2) * (r1 + r2);
    if (radSumSq>=distSq)
        return 1;
    return 0;
}
vector<int>adj[(int)1e3+5];
vector<bool>vis(1e3+3,0);
vector<vector<short>>dp(1e3+3,vector<short>(1e3+3,-1));
bool dfs(int curnode,int m){
    if(curnode==m)
        return 1;
    //if(dp[curnode][m]!=-1)
    //    return dp[curnode][m];
    if(vis[curnode])
        return 0;
    vis[curnode]=1;
    bool ret=0;
    for(int child:adj[curnode]){
        ret|=dfs(child,m);
    }
    return dp[curnode][m]=ret;
}
int n;
pair<long double,long double> a[(int)1e3+5];
bool check(long double r){
    for(int i = 0; i <= 1e3; i++)
        adj[i]=vector<int>(1e3+3);
    vis=vector<bool>(1e3+3,0);
    dp=vector<vector<short>>(1e3+3,vector<short>(1e3+3,-1));
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(touch(a[i].first,a[i].second,
                a[j].first,a[j].second,r,r)){
                adj[i].push_back(j);
                adj[j].push_back(i);
            }
        }
    }
    bool ok=1;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            vis=vector<bool>(1e2+3,0);
            ok&=dfs(i,j);
        }
    }
    return ok;
}
int main()
{
    ACPLS();
    cin>>n;
    for(int i = 0; i < n; i++)
        cin>>a[i].first>>a[i].second;
    double lo=0,hi=1e9,ans=hi;
    int it=0;
    while(it<60){
        double mid = (lo+hi)*0.5;
        if(check(mid)){
            ans=mid;
            hi=mid;
        }
        else lo=mid;
        ++it;
    }
    cout<<fixed<<setprecision(6);
    cout<<ans;
}

Compilation message

odasiljaci.cpp: In function 'bool dfs(int, int)':
odasiljaci.cpp:42:26: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   42 |     return dp[curnode][m]=ret;
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 8320 KB Output is correct
2 Correct 167 ms 8368 KB Output is correct
3 Execution timed out 1092 ms 8424 KB Time limit exceeded
4 Execution timed out 1091 ms 8268 KB Time limit exceeded
5 Execution timed out 1090 ms 8268 KB Time limit exceeded
6 Runtime error 19 ms 16664 KB Execution killed with signal 6
7 Runtime error 19 ms 16724 KB Execution killed with signal 6
8 Runtime error 23 ms 18576 KB Execution killed with signal 6
9 Runtime error 30 ms 20556 KB Execution killed with signal 6
10 Runtime error 34 ms 20864 KB Execution killed with signal 6