Submission #1018740

#TimeUsernameProblemLanguageResultExecution timeMemory
1018740AmirAli_H1Towns (IOI15_towns)C++17
25 / 100
16 ms976 KiB
// In the name of Allah #include <bits/stdc++.h> #include "towns.h" using namespace std; typedef long long int ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef complex<ld> cld; #define all(x) (x).begin(),(x).end() #define len(x) ((ll) (x).size()) #define F first #define S second #define pb push_back #define sep ' ' #define endl '\n' #define Mp make_pair #define kill(x) cout << x << '\n', exit(0) #define set_dec(x) cout << fixed << setprecision(x); #define file_io(x,y) freopen(x, "r", stdin); freopen(y, "w", stdout); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; const int maxn = 110 + 4; ll D1[maxn], D2[maxn]; int hubDistance(int N, int sub) { n = N; ll mx = 0; int u1 = 0; for (int i = 0; i < n; i++) { if (i == 0) continue; ll d = getDistance(0, i); if (d >= mx) { mx = d; u1 = i; } } mx = 0; int u2 = u1; for (int i = 0; i < n; i++) { if (i == u1) { D1[i] = 0; continue; } D1[i] = getDistance(u1, i); if (D1[i] >= mx) { mx = D1[i]; u2 = i; } } for (int i = 0; i < n; i++) { if (i == u2) { D2[i] = 0; continue; } D2[i] = getDistance(u2, i); } ll dx = D1[u2], R = dx; for (int i = 0; i < n; i++) { ll x = (D1[i] + D2[i] - dx) / 2; R = min(R, max(D1[i] - x, D2[i] - x)); } return R; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:67:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   67 |  return R;
      |         ^
towns.cpp:30:28: warning: unused parameter 'sub' [-Wunused-parameter]
   30 | 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...