제출 #1065173

#제출 시각아이디문제언어결과실행 시간메모리
1065173pawned도시들 (IOI15_towns)C++17
35 / 100
13 ms484 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]; // cout<<"a, b, dia: "<<a<<", "<<b<<"; "<<dia<<endl; 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; map<int, int> cnts; for (int i = 0; i < N; i++) { cnts[dist1[i] - dist2[i]]++; } /* cout<<"cnts: "<<endl; for (ii p : cnts) cout<<p.fi<<": "<<p.se<<endl;*/ int ctr = 0; for (ii p : cnts) { if (((dia + abs(p.fi)) / 2 == ans) && (p.se <= N / 2) && (ctr <= N / 2) && (N - p.se - ctr <= N / 2)) return ans; ctr += p.se; } 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...