Submission #1096994

#TimeUsernameProblemLanguageResultExecution timeMemory
1096994thangdz2k7City Mapping (NOI18_citymapping)C++17
Compilation error
0 ms0 KiB
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int N = 1e3 + 5; const int mod = 1e9 + 7; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} ll d[N][N]; ll dist(int x, int y){ if (x > y) swap(x, y); if (x == y) return 0; if (!d[x][y]) d[x][y] = get_distance(x, y); return d[x][y]; } bool del[N]; int sz[N], heavy[N]; vi adj[N]; void dfs(int u){ sz[u] = 1, heavy[u] = 0; for (int v : adj[u]) if (!del[v]){ dfs(v); sz[u] += sz[v]; if (sz[v] > sz[heavy[u]]) heavy[u] = v; } } void find_roads(int n, int q, int a[], int b[], int w[]){ vector <int> sr; for (int i = 2; i < n + 1; ++ i) sr.pb(i); sort(sr.begin(), sr.end(), [&](int u, int v){ return dist(1, x) < dist(1, y); }); int nE = 0; for (int u : sr){ int r = 1; for (int i = 1; i <= n; ++ i) del[i] = 0; while (true){ dfs(r); vi path = {r}; while (heavy[r]) r = heavy[r], path.pb(r); if (path.size() == 1) break; ll x = dist(1, path.back()) + dist(1, u) - dist(u, r.back()); x /= 2; for (int u : path) if (dist(1, u) == x) { r = u; break; } else del[u] = 1; } adj[r].pb(u); a[nE] = r, b[nE] = u, w[nE] = dist(r, u), ++ nE; } } //void solve(){ // //} // //int main(){ // if (fopen("pqh.inp", "r")){ // freopen("pqh.inp", "r", stdin); // freopen("pqh.out", "w", stdout); // } // ios_base::sync_with_stdio(0); // cin.tie(0); cout.tie(0); // // int t = 1; // cin >> t; // while (t --) solve(); // return 0; //}

Compilation message (stderr)

citymapping.cpp:18:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |           ^~~~
citymapping.cpp:18:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   18 | void maxl(auto &a, auto b) {a = max(a, b);}
      |                    ^~~~
citymapping.cpp:19:11: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |           ^~~~
citymapping.cpp:19:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   19 | void minl(auto &a, auto b) {a = min(a, b);}
      |                    ^~~~
citymapping.cpp: In function 'll dist(int, int)':
citymapping.cpp:26:29: error: 'get_distance' was not declared in this scope
   26 |     if (!d[x][y]) d[x][y] = get_distance(x, y);
      |                             ^~~~~~~~~~~~
citymapping.cpp: In lambda function:
citymapping.cpp:47:24: error: 'x' was not declared in this scope
   47 |         return dist(1, x) < dist(1, y);
      |                        ^
citymapping.cpp:47:37: error: 'y' was not declared in this scope
   47 |         return dist(1, x) < dist(1, y);
      |                                     ^
citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:58:66: error: request for member 'back' in 'r', which is of non-class type 'int'
   58 |             ll x = dist(1, path.back()) + dist(1, u) - dist(u, r.back()); x /= 2;
      |                                                                  ^~~~