# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592709 | 2022-07-09T13:43:55 Z | Blagojce | City Mapping (NOI18_citymapping) | C++11 | 9 ms | 8300 KB |
#include <bits/stdc++.h> #define fr(i, n, m) for(int i = (n); i < (m); i ++) #define st first #define nd second #define pb push_back #define pq priority_queue #define all(x) begin(x), end(x) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int mxn = 1003; mt19937 _rand(time(NULL)); clock_t z; #include "citymapping.h" ll dist[mxn][mxn];/* ll get_distance(int x, int y){ cout<<"? "<<x<<' '<<y<<endl; ll ret; cin >> ret; return ret; }*/ ll ask(int x, int y){ if(x != y && dist[x][y] == 0){ dist[x][y] = dist[y][x] = get_distance(x+1, y+1); } return dist[x][y]; } vector<int> g; int R1, R2; int AA[mxn], BB[mxn], WW[mxn]; int edge_id = 0; void add_edge(int x, int y, int w){ AA[edge_id] = x; BB[edge_id] = y; WW[edge_id] = w; edge_id ++; } void decompose(vector<int> v){ int r1 = v[_rand() % (int)v.size()]; int r2 = v[_rand() % (int)v.size()]; g = v; if((int)g.size() <= 1) return; for(auto u : g){ ask(u, r1); } /*for(auto u : g){ if(dist[r1][u] > dist[r1][r2]){ r2 = u; } }*/ for(auto u : g){ ask(u, r2); } R1 = r1; R2 = r2; sort(all(g), [](const int &i, const int &j){ return dist[R1][i] < dist[R1][j]; }); vector<int> diam; for(auto u : g){ if(dist[r1][u] + dist[u][r2] == dist[r1][r2]){ diam.pb(u); } } fr(i, 1, (int)diam.size()){ add_edge(diam[i-1], diam[i], dist[r1][diam[i]] - dist[r1][diam[i-1]]); } vector<int> sub[(int)diam.size()]; fr(i, 0, (int)diam.size()){ sub[i].pb(diam[i]); } for(auto u : g){ if(dist[r1][u] + dist[u][r2] == dist[r1][r2]) continue; fr(i, 0, (int)diam.size()){ auto d = diam[i]; if(dist[r1][u] - dist[r2][u] == dist[r1][d] - dist[r2][d]){ sub[i].pb(u); break; } } } fr(i, 0, (int)diam.size()){ decompose(sub[i]); } } void find_roads(int N, int Q, int A[], int B[], int W[]) { vector<int> v; fr(i, 0, N) v.pb(i); decompose(v); fr(i, 0, N-1){ A[i] = AA[i] + 1; B[i] = BB[i] + 1; W[i] = WW[i]; } return; }
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7764 KB | Correct: 5637 out of 500000 queries used. |
2 | Correct | 7 ms | 8276 KB | Correct: 5608 out of 500000 queries used. |
3 | Correct | 6 ms | 8276 KB | Correct: 9311 out of 500000 queries used. |
4 | Correct | 6 ms | 8276 KB | Correct: 7782 out of 500000 queries used. |
5 | Correct | 6 ms | 8148 KB | Correct: 8249 out of 500000 queries used. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7764 KB | Correct: 5637 out of 500000 queries used. |
2 | Correct | 7 ms | 8276 KB | Correct: 5608 out of 500000 queries used. |
3 | Correct | 6 ms | 8276 KB | Correct: 9311 out of 500000 queries used. |
4 | Correct | 6 ms | 8276 KB | Correct: 7782 out of 500000 queries used. |
5 | Correct | 6 ms | 8148 KB | Correct: 8249 out of 500000 queries used. |
6 | Correct | 6 ms | 7904 KB | Correct: 5607 out of 500000 queries used. |
7 | Correct | 5 ms | 7892 KB | Correct: 4122 out of 500000 queries used. |
8 | Correct | 7 ms | 8276 KB | Correct: 7598 out of 500000 queries used. |
9 | Correct | 7 ms | 8276 KB | Correct: 10770 out of 500000 queries used. |
10 | Correct | 6 ms | 8276 KB | Correct: 7312 out of 500000 queries used. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 6996 KB | Correct: 5671 out of 12000 queries used. |
2 | Correct | 6 ms | 7892 KB | Correct: 6133 out of 12000 queries used. |
3 | Correct | 6 ms | 8276 KB | Correct: 7443 out of 12000 queries used. |
4 | Correct | 6 ms | 7892 KB | Correct: 7085 out of 12000 queries used. |
5 | Correct | 5 ms | 7380 KB | Correct: 3723 out of 12000 queries used. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 6996 KB | Correct: 5671 out of 12000 queries used. |
2 | Correct | 6 ms | 7892 KB | Correct: 6133 out of 12000 queries used. |
3 | Correct | 6 ms | 8276 KB | Correct: 7443 out of 12000 queries used. |
4 | Correct | 6 ms | 7892 KB | Correct: 7085 out of 12000 queries used. |
5 | Correct | 5 ms | 7380 KB | Correct: 3723 out of 12000 queries used. |
6 | Correct | 6 ms | 8184 KB | Correct: 6743 out of 12000 queries used. |
7 | Correct | 5 ms | 7764 KB | Correct: 3507 out of 12000 queries used. |
8 | Correct | 7 ms | 8268 KB | Correct: 5046 out of 12000 queries used. |
9 | Correct | 6 ms | 7420 KB | Correct: 5956 out of 12000 queries used. |
10 | Correct | 6 ms | 7540 KB | Correct: 6338 out of 12000 queries used. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 7764 KB | Correct: 5637 out of 500000 queries used. |
2 | Correct | 7 ms | 8276 KB | Correct: 5608 out of 500000 queries used. |
3 | Correct | 6 ms | 8276 KB | Correct: 9311 out of 500000 queries used. |
4 | Correct | 6 ms | 8276 KB | Correct: 7782 out of 500000 queries used. |
5 | Correct | 6 ms | 8148 KB | Correct: 8249 out of 500000 queries used. |
6 | Correct | 6 ms | 7904 KB | Correct: 5607 out of 500000 queries used. |
7 | Correct | 5 ms | 7892 KB | Correct: 4122 out of 500000 queries used. |
8 | Correct | 7 ms | 8276 KB | Correct: 7598 out of 500000 queries used. |
9 | Correct | 7 ms | 8276 KB | Correct: 10770 out of 500000 queries used. |
10 | Correct | 6 ms | 8276 KB | Correct: 7312 out of 500000 queries used. |
11 | Correct | 5 ms | 6996 KB | Correct: 5671 out of 12000 queries used. |
12 | Correct | 6 ms | 7892 KB | Correct: 6133 out of 12000 queries used. |
13 | Correct | 6 ms | 8276 KB | Correct: 7443 out of 12000 queries used. |
14 | Correct | 6 ms | 7892 KB | Correct: 7085 out of 12000 queries used. |
15 | Correct | 5 ms | 7380 KB | Correct: 3723 out of 12000 queries used. |
16 | Correct | 6 ms | 8184 KB | Correct: 6743 out of 12000 queries used. |
17 | Correct | 5 ms | 7764 KB | Correct: 3507 out of 12000 queries used. |
18 | Correct | 7 ms | 8268 KB | Correct: 5046 out of 12000 queries used. |
19 | Correct | 6 ms | 7420 KB | Correct: 5956 out of 12000 queries used. |
20 | Correct | 6 ms | 7540 KB | Correct: 6338 out of 12000 queries used. |
21 | Correct | 7 ms | 8020 KB | Correct: 4053 out of 25000 queries used. |
22 | Correct | 6 ms | 7208 KB | Correct: 3347 out of 25000 queries used. |
23 | Correct | 7 ms | 8192 KB | Correct: 7689 out of 25000 queries used. |
24 | Correct | 8 ms | 7764 KB | Correct: 4683 out of 25000 queries used. |
25 | Correct | 9 ms | 8276 KB | Correct: 8320 out of 25000 queries used. |
26 | Correct | 8 ms | 8248 KB | Correct: 8522 out of 25000 queries used. |
27 | Correct | 7 ms | 8144 KB | Correct: 7833 out of 25000 queries used. |
28 | Correct | 7 ms | 8256 KB | Correct: 8708 out of 25000 queries used. |
29 | Correct | 7 ms | 8276 KB | Correct: 7673 out of 25000 queries used. |
30 | Correct | 8 ms | 8148 KB | Correct: 8351 out of 25000 queries used. |
31 | Correct | 7 ms | 8276 KB | Correct: 9943 out of 25000 queries used. |
32 | Correct | 5 ms | 6996 KB | Correct: 6116 out of 25000 queries used. |
33 | Correct | 6 ms | 8148 KB | Correct: 8109 out of 25000 queries used. |
34 | Correct | 7 ms | 8276 KB | Correct: 7552 out of 25000 queries used. |
35 | Correct | 7 ms | 8252 KB | Correct: 7320 out of 25000 queries used. |
36 | Correct | 6 ms | 8276 KB | Correct: 8410 out of 25000 queries used. |
37 | Correct | 7 ms | 8148 KB | Correct: 7856 out of 25000 queries used. |
38 | Correct | 7 ms | 8248 KB | Correct: 7912 out of 25000 queries used. |
39 | Correct | 9 ms | 8276 KB | Correct: 8455 out of 25000 queries used. |
40 | Correct | 6 ms | 8228 KB | Correct: 7941 out of 25000 queries used. |
41 | Correct | 6 ms | 8276 KB | Correct: 8236 out of 25000 queries used. |
42 | Correct | 7 ms | 8228 KB | Correct: 10026 out of 25000 queries used. |
43 | Correct | 5 ms | 6484 KB | Correct: 3941 out of 25000 queries used. |
44 | Correct | 7 ms | 8148 KB | Correct: 8509 out of 25000 queries used. |
45 | Correct | 6 ms | 8276 KB | Correct: 8174 out of 25000 queries used. |
46 | Correct | 7 ms | 8240 KB | Correct: 9417 out of 25000 queries used. |
47 | Correct | 6 ms | 8300 KB | Correct: 8605 out of 25000 queries used. |
48 | Correct | 6 ms | 8272 KB | Correct: 8177 out of 25000 queries used. |
49 | Correct | 6 ms | 8148 KB | Correct: 7556 out of 25000 queries used. |
50 | Correct | 6 ms | 8276 KB | Correct: 8602 out of 25000 queries used. |
51 | Correct | 6 ms | 8276 KB | Correct: 7680 out of 25000 queries used. |
52 | Correct | 7 ms | 8276 KB | Correct: 8478 out of 25000 queries used. |
53 | Correct | 7 ms | 8276 KB | Correct: 8574 out of 25000 queries used. |
54 | Correct | 5 ms | 6996 KB | Correct: 2836 out of 25000 queries used. |
55 | Correct | 8 ms | 8276 KB | Correct: 9877 out of 25000 queries used. |
56 | Correct | 9 ms | 8276 KB | Correct: 7716 out of 25000 queries used. |
57 | Correct | 7 ms | 8276 KB | Correct: 8849 out of 25000 queries used. |
58 | Correct | 7 ms | 8148 KB | Correct: 8060 out of 25000 queries used. |
59 | Correct | 6 ms | 8148 KB | Correct: 8370 out of 25000 queries used. |
60 | Correct | 6 ms | 8224 KB | Correct: 8382 out of 25000 queries used. |
61 | Correct | 6 ms | 8284 KB | Correct: 7685 out of 25000 queries used. |
62 | Correct | 9 ms | 8080 KB | Correct: 8317 out of 25000 queries used. |
63 | Correct | 6 ms | 8020 KB | Correct: 5505 out of 25000 queries used. |
64 | Correct | 6 ms | 8276 KB | Correct: 6204 out of 25000 queries used. |
65 | Correct | 6 ms | 8148 KB | Correct: 7679 out of 25000 queries used. |
66 | Correct | 7 ms | 8276 KB | Correct: 7951 out of 25000 queries used. |
67 | Correct | 6 ms | 8276 KB | Correct: 7310 out of 25000 queries used. |
68 | Correct | 7 ms | 8224 KB | Correct: 5513 out of 25000 queries used. |
69 | Correct | 7 ms | 8276 KB | Correct: 5019 out of 25000 queries used. |
70 | Correct | 7 ms | 8148 KB | Correct: 5197 out of 25000 queries used. |