제출 #359831

#제출 시각아이디문제언어결과실행 시간메모리
359831kylych03도시들 (IOI15_towns)C++14
35 / 100
26 ms408 KiB
#include "towns.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; int d1[1000]; int d2[1000]; int hubDistance(int N, int sub) { int mx = 0, u1, x , u2; for(int i = 1; i < N; i++){ x = getDistance(0,i); if(x >= mx){ mx = x; u1 = i; } } d1[0]=mx; mx = 0; for(int i = 0; i < N; i++){ d1[i]=getDistance(u1,i); if(d1[i] >= mx){ mx = d1[i]; u2 = i; } } d2[u1] = mx; int diam = mx; int res = diam; for(int i = 0; i < N; i++){ d2[i]=getDistance(u2,i); int len = (d1[i] + d2[i] - diam ) / 2; len = d2[i] - len; res = min(res, max(len, diam - len)); } int l=0, r=0, m=0; for(int i = 0 ; i < N ;i++){ x = d1[i] - (d1[i] + d2[i] - diam ) / 2; if(x > res) r++; else if(x < res) l++; else{ u1 = i; m++; } } //cout << m << " " << l <<" " << r << endl; if(N/2 >= m && N/2 >= l && N/2 >= r ) return res; l=0, r=0, m=0; for(int i = 0 ; i < N ;i++){ x = d2[i] - (d1[i] + d2[i] - diam ) / 2; if(x > res) r++; else if(x < res) l++; else{ u2=i; m++; } } if(N/2 >= m && N/2 >= l && N/2 >= r ) return res; /*for(int i = 0 ; i < N ;i++){ getDistance(u2,i); }*/ return -res; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:7:28: warning: unused parameter 'sub' [-Wunused-parameter]
    7 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
towns.cpp:27:9: warning: 'u1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |  d2[u1] = mx;
      |  ~~~~~~~^~~~
towns.cpp:32:20: warning: 'u2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |   d2[i]=getDistance(u2,i);
      |         ~~~~~~~~~~~^~~~~~
#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...