Submission #1122928

#TimeUsernameProblemLanguageResultExecution timeMemory
1122928gustavo_dTowns (IOI15_towns)C++17
0 / 100
1096 ms1740 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 110; int cnt; int cache[MAXN][MAXN]; int dist(int a, int b) { if (a > b) swap(a, b); if (a == b) return 0; if (cache[a][b] != -1) return cache[a][b]; cnt--; assert(cnt >= 0); cerr << "get "<< a << ' ' << b << endl; return cache[a][b] = getDistance(a, b); } int hubDistance(int n, int sub) { for (int i=0; i<n; i++) { for (int j=0; j<n; j++) { cache[i][j] = -1; } } cnt = n*(n-1)/2; int r = 1e9; if (sub == 1 or true) { for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { cerr << endl << endl; cerr << "Olhando: " << i << ' ' << j << endl; map<pair<int, int>, int> mx_dist; for (int k=0; k<n; k++) { if (k == i or k == j) continue; int a = (dist(i, k) + dist(j, k) - dist(i, j)) / 2; int x = dist(i, k) - a; int y = dist(j, k) - a; mx_dist[{x, y}] = max({mx_dist[{x, y}], a, x, y}); cerr << k << ':' << x << ' ' << y << ' ' << a << endl; cerr << dist(i, k) << ' ' << dist(j, k) << ' ' << dist(i, j) << endl; } int pf[(int)mx_dist.size()+1]; pf[0] = 0; int pf_i = 1; int last_x = 0; for (auto it=mx_dist.begin(); it != mx_dist.end(); it++, pf_i++) { auto [x, y] = it->first; int mx = it->second; pf[pf_i] = max(mx, x-last_x + pf[pf_i-1]); last_x = x; } int sf[(int)mx_dist.size()+1]; sf[(int)mx_dist.size()] = 0; int sf_i = (int)mx_dist.size()-1; int last_y = 0; for (auto it = mx_dist.end(); it != mx_dist.begin(); sf_i--) { it--; auto [x, y] = it->first; int mx = it->second; sf[sf_i] = max(mx, y-last_y + sf[sf_i+1]); last_y = y; cerr << x << ' ' << y << '=' << max(sf[sf_i], pf[sf_i+1]) << endl; } for (int pt=0; pt<(int)mx_dist.size(); pt++) { if (max(pf[pt+1], sf[pt]) == 16) cerr << pt << endl; r = min(r, max(pf[pt+1], sf[pt])); } } } } return r; }
#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...