# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
200626 | 2020-02-07T16:22:37 Z | wilwxk | City Mapping (NOI18_citymapping) | C++14 | 16 ms | 7160 KB |
#include "citymapping.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e3+5; ll dist[MAXN][MAXN]; vector<tuple<int, int, int> > ans; vector<int> subtree[MAXN]; ll further[MAXN][2]; mt19937 rng(time(0)); int n; ll query(int a, int b) { if(a == b) return 0; if(a > b) swap(a, b); if(dist[a][b]) return dist[a][b]; // printf("query %d %d\n", a, b); return dist[a][b] = get_distance(a, b); } void solve(int cur) { if(subtree[cur].size() == 1) return; int x = further[cur][0]; int y = x; for(auto vertex : subtree[cur]) if(query(x, vertex) > query(x, y)) y = vertex; // printf("solve %d >> %d %d\n", cur, x, y); for(auto vertex : subtree[cur]) printf("%d ", vertex); cout << endl; vector<pair<ll, int> > line; vector<pair<ll, int> > aux; for(int vertex : subtree[cur]) { ll val = query(x, vertex) + query(y, vertex) - query(x, y); val /= 2; if(val == 0) line.push_back({query(x, vertex), vertex}); val = query(x, y) - query(vertex, y) + val; aux.push_back({val, vertex}); } sort(line.begin(), line.end()); sort(aux.begin(), aux.end()); subtree[cur].clear(); further[cur][0] = 0; further[cur][1] = -1; int p = 0; for(int i = 0; i < line.size(); i++) { int vertex = line[i].second; ll dx = line[i].first; while(p < aux.size() && aux[p].first == dx) { ll val = query(x, aux[p].second) - dx; if(val > further[vertex][1]) further[vertex][0] = aux[p].second, further[vertex][1] = val; subtree[vertex].push_back(aux[p++].second); } if(i != 0) ans.push_back({vertex, line[i-1].second, line[i].first-line[i-1].first}); } for(auto item : line) solve(item.second); } void find_roads(int N, int Q, int A[], int B[], int W[]) { n = N; int ori = rng()%n +1; for(int i = 1; i <= n; i++) subtree[ori].push_back(i); for(int i = 1; i <= n; i++) if(query(ori, i) > further[ori][1]) further[ori][0] = i, further[ori][1] = query(ori, i); solve(ori); for(int i = 0; i < ans.size(); i++) tie(A[i], B[i], W[i]) = ans[i]; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 3064 KB | Correct: 2991 out of 500000 queries used. |
2 | Correct | 9 ms | 4856 KB | Correct: 3492 out of 500000 queries used. |
3 | Correct | 10 ms | 5112 KB | Correct: 6758 out of 500000 queries used. |
4 | Correct | 11 ms | 5368 KB | Correct: 7646 out of 500000 queries used. |
5 | Correct | 12 ms | 6648 KB | Correct: 12071 out of 500000 queries used. |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 3064 KB | Correct: 2991 out of 500000 queries used. |
2 | Correct | 9 ms | 4856 KB | Correct: 3492 out of 500000 queries used. |
3 | Correct | 10 ms | 5112 KB | Correct: 6758 out of 500000 queries used. |
4 | Correct | 11 ms | 5368 KB | Correct: 7646 out of 500000 queries used. |
5 | Correct | 12 ms | 6648 KB | Correct: 12071 out of 500000 queries used. |
6 | Correct | 10 ms | 5752 KB | Correct: 2982 out of 500000 queries used. |
7 | Correct | 13 ms | 7160 KB | Correct: 20997 out of 500000 queries used. |
8 | Correct | 12 ms | 6776 KB | Correct: 6894 out of 500000 queries used. |
9 | Correct | 11 ms | 6264 KB | Correct: 8032 out of 500000 queries used. |
10 | Correct | 11 ms | 6136 KB | Correct: 7619 out of 500000 queries used. |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 5752 KB | Correct: 2967 out of 12000 queries used. |
2 | Correct | 8 ms | 2680 KB | Correct: 2973 out of 12000 queries used. |
3 | Correct | 9 ms | 3960 KB | Correct: 2994 out of 12000 queries used. |
4 | Correct | 7 ms | 2680 KB | Correct: 2973 out of 12000 queries used. |
5 | Correct | 9 ms | 5112 KB | Correct: 2967 out of 12000 queries used. |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 5752 KB | Correct: 2967 out of 12000 queries used. |
2 | Correct | 8 ms | 2680 KB | Correct: 2973 out of 12000 queries used. |
3 | Correct | 9 ms | 3960 KB | Correct: 2994 out of 12000 queries used. |
4 | Correct | 7 ms | 2680 KB | Correct: 2973 out of 12000 queries used. |
5 | Correct | 9 ms | 5112 KB | Correct: 2967 out of 12000 queries used. |
6 | Correct | 11 ms | 6392 KB | Correct: 2988 out of 12000 queries used. |
7 | Correct | 10 ms | 5880 KB | Correct: 2982 out of 12000 queries used. |
8 | Correct | 10 ms | 5624 KB | Correct: 2994 out of 12000 queries used. |
9 | Correct | 9 ms | 3960 KB | Correct: 2985 out of 12000 queries used. |
10 | Correct | 8 ms | 3448 KB | Correct: 2976 out of 12000 queries used. |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 3064 KB | Correct: 2991 out of 500000 queries used. |
2 | Correct | 9 ms | 4856 KB | Correct: 3492 out of 500000 queries used. |
3 | Correct | 10 ms | 5112 KB | Correct: 6758 out of 500000 queries used. |
4 | Correct | 11 ms | 5368 KB | Correct: 7646 out of 500000 queries used. |
5 | Correct | 12 ms | 6648 KB | Correct: 12071 out of 500000 queries used. |
6 | Correct | 10 ms | 5752 KB | Correct: 2982 out of 500000 queries used. |
7 | Correct | 13 ms | 7160 KB | Correct: 20997 out of 500000 queries used. |
8 | Correct | 12 ms | 6776 KB | Correct: 6894 out of 500000 queries used. |
9 | Correct | 11 ms | 6264 KB | Correct: 8032 out of 500000 queries used. |
10 | Correct | 11 ms | 6136 KB | Correct: 7619 out of 500000 queries used. |
11 | Correct | 11 ms | 5752 KB | Correct: 2967 out of 12000 queries used. |
12 | Correct | 8 ms | 2680 KB | Correct: 2973 out of 12000 queries used. |
13 | Correct | 9 ms | 3960 KB | Correct: 2994 out of 12000 queries used. |
14 | Correct | 7 ms | 2680 KB | Correct: 2973 out of 12000 queries used. |
15 | Correct | 9 ms | 5112 KB | Correct: 2967 out of 12000 queries used. |
16 | Correct | 11 ms | 6392 KB | Correct: 2988 out of 12000 queries used. |
17 | Correct | 10 ms | 5880 KB | Correct: 2982 out of 12000 queries used. |
18 | Correct | 10 ms | 5624 KB | Correct: 2994 out of 12000 queries used. |
19 | Correct | 9 ms | 3960 KB | Correct: 2985 out of 12000 queries used. |
20 | Correct | 8 ms | 3448 KB | Correct: 2976 out of 12000 queries used. |
21 | Correct | 8 ms | 3320 KB | Correct: 2982 out of 25000 queries used. |
22 | Correct | 10 ms | 5240 KB | Correct: 6738 out of 25000 queries used. |
23 | Correct | 9 ms | 4600 KB | Correct: 3539 out of 25000 queries used. |
24 | Correct | 10 ms | 6524 KB | Correct: 4916 out of 25000 queries used. |
25 | Correct | 12 ms | 7160 KB | Correct: 6923 out of 25000 queries used. |
26 | Correct | 10 ms | 5496 KB | Correct: 6681 out of 25000 queries used. |
27 | Correct | 11 ms | 5880 KB | Correct: 6744 out of 25000 queries used. |
28 | Correct | 16 ms | 6008 KB | Correct: 7073 out of 25000 queries used. |
29 | Correct | 11 ms | 6264 KB | Correct: 7288 out of 25000 queries used. |
30 | Correct | 11 ms | 6008 KB | Correct: 7603 out of 25000 queries used. |
31 | Correct | 11 ms | 6648 KB | Correct: 7712 out of 25000 queries used. |
32 | Correct | 9 ms | 4984 KB | Correct: 2979 out of 25000 queries used. |
33 | Correct | 11 ms | 6392 KB | Correct: 7711 out of 25000 queries used. |
34 | Correct | 11 ms | 6904 KB | Correct: 7684 out of 25000 queries used. |
35 | Correct | 12 ms | 6776 KB | Correct: 7692 out of 25000 queries used. |
36 | Correct | 11 ms | 6136 KB | Correct: 7764 out of 25000 queries used. |
37 | Correct | 11 ms | 6136 KB | Correct: 7639 out of 25000 queries used. |
38 | Correct | 11 ms | 6264 KB | Correct: 7792 out of 25000 queries used. |
39 | Correct | 12 ms | 7032 KB | Correct: 7672 out of 25000 queries used. |
40 | Correct | 11 ms | 6136 KB | Correct: 7742 out of 25000 queries used. |
41 | Correct | 11 ms | 6392 KB | Correct: 7692 out of 25000 queries used. |
42 | Correct | 12 ms | 6904 KB | Correct: 7701 out of 25000 queries used. |
43 | Correct | 11 ms | 4600 KB | Correct: 2988 out of 25000 queries used. |
44 | Correct | 12 ms | 6264 KB | Correct: 7626 out of 25000 queries used. |
45 | Correct | 12 ms | 6960 KB | Correct: 7618 out of 25000 queries used. |
46 | Correct | 11 ms | 5880 KB | Correct: 7618 out of 25000 queries used. |
47 | Correct | 11 ms | 6264 KB | Correct: 7696 out of 25000 queries used. |
48 | Correct | 12 ms | 6776 KB | Correct: 7710 out of 25000 queries used. |
49 | Correct | 12 ms | 6136 KB | Correct: 7698 out of 25000 queries used. |
50 | Correct | 12 ms | 6776 KB | Correct: 7721 out of 25000 queries used. |
51 | Correct | 12 ms | 6908 KB | Correct: 7706 out of 25000 queries used. |
52 | Correct | 11 ms | 6264 KB | Correct: 7686 out of 25000 queries used. |
53 | Correct | 11 ms | 6520 KB | Correct: 8008 out of 25000 queries used. |
54 | Correct | 15 ms | 6776 KB | Correct: 22612 out of 25000 queries used. |
55 | Correct | 12 ms | 6008 KB | Correct: 7701 out of 25000 queries used. |
56 | Correct | 12 ms | 6904 KB | Correct: 7762 out of 25000 queries used. |
57 | Correct | 12 ms | 6648 KB | Correct: 8072 out of 25000 queries used. |
58 | Correct | 11 ms | 6648 KB | Correct: 7628 out of 25000 queries used. |
59 | Correct | 11 ms | 6268 KB | Correct: 7636 out of 25000 queries used. |
60 | Correct | 11 ms | 6012 KB | Correct: 8844 out of 25000 queries used. |
61 | Correct | 11 ms | 6136 KB | Correct: 8338 out of 25000 queries used. |
62 | Correct | 11 ms | 6264 KB | Correct: 7758 out of 25000 queries used. |
63 | Correct | 11 ms | 6264 KB | Correct: 8376 out of 25000 queries used. |
64 | Correct | 12 ms | 7032 KB | Correct: 7948 out of 25000 queries used. |
65 | Correct | 11 ms | 6776 KB | Correct: 10760 out of 25000 queries used. |
66 | Correct | 13 ms | 5880 KB | Correct: 7833 out of 25000 queries used. |
67 | Correct | 9 ms | 4856 KB | Correct: 3851 out of 25000 queries used. |
68 | Incorrect | 13 ms | 6392 KB | Too many calls to get_distance(). |
69 | Halted | 0 ms | 0 KB | - |