제출 #410062

#제출 시각아이디문제언어결과실행 시간메모리
410062definitelynotmeeTowns (IOI15_towns)C++98
25 / 100
20 ms952 KiB
#include <bits/stdc++.h>
//#include "towns.h"
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INFL = (1LL<<62)-1;
const int INF = (1<<30)-1;
const int MAXN = 0;

int getDistance(int i, int j);

int hubDistance(int n, int sub){

    vector<int> ds (n,0), db(n,0), da(n,-1);

    int a = 0, b;
    int maxi = -1;
    for(int i = 1; i < n; i++){
        ds[i] = getDistance(0,i);
        if(ds[i] > maxi)
            maxi = ds[i], b = i;
    }
    maxi = ds[b];
    db[0] = ds[b];
    for(int i = 1; i < n; i++){
        if(i==b)
            continue;
        db[i] = getDistance(b,i);
        if(db[i] > maxi)
            maxi = db[i], a = i;
    }
    da[a] = 0;
    da[b] = db[a];
    da[0] = ds[a];
    vector<int> dlca(n,0), v(n,0);
    int resp = INF;
    for(int i = 0; i < n; i++){
        dlca[i] = (db[0] + db[i] - ds[i])>>1;
        resp = min(resp, max(dlca[i], db[a] - dlca[i]));
    }
    
    

    return resp;
}

컴파일 시 표준 에러 (stderr) 메시지

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:17:28: warning: unused parameter 'sub' [-Wunused-parameter]
   17 | int hubDistance(int n, int sub){
      |                        ~~~~^~~
towns.cpp:28:16: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 |     maxi = ds[b];
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...