제출 #1065168

#제출 시각아이디문제언어결과실행 시간메모리
1065168pawned도시들 (IOI15_towns)C++17
25 / 100
10 ms488 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; #include "towns.h" int hubDistance(int N, int sub) { int a = -1; int maxd = -1; for (int i = 0; i < N; i++) { int cdist = getDistance(0, i); if (cdist > maxd) { a = i; maxd = cdist; } } int b = -1; maxd = -1; vi dist1(N, -1); for (int i = 0; i < N; i++) { dist1[i] = getDistance(a, i); if (dist1[i] > maxd) { b = i; maxd = dist1[i]; } } vi dist2(N, -1); for (int i = 0; i < N; i++) { dist2[i] = getDistance(b, i); } int dia = dist1[b]; int ans = 1e9; for (int i = 0; i < N; i++) { int s = (dia + abs(dist1[i] - dist2[i])) / 2; ans = min(ans, s); } vi cen; for (int i = 0; i < N; i++) { if ((dia + abs(dist1[i] - dist2[i])) / 2 == ans) cen.pb(i); } for (int x : cen) { int cnt = 0; for (int i = 0; i < N; i++) { if (dist1[i] - dist2[i] == dist1[x] - dist2[x]) cnt++; } if (cnt <= N / 2) return ans; } return -ans; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:15:28: warning: unused parameter 'sub' [-Wunused-parameter]
   15 | int hubDistance(int N, int sub) {
      |                        ~~~~^~~
#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...