Submission #321751

#TimeUsernameProblemLanguageResultExecution timeMemory
321751wind_reaperCity Mapping (NOI18_citymapping)C++17
Compilation error
0 ms0 KiB
#include "citymapping.h" #include <bits/stdc++.h> using namespace std; struct DSU{ vi e; void init(int n){ e = vi(n, -1); } int get(int x){ return (e[x] < 0 ? x : e[x] = get(e[x])); } bool same_set(int x, int y){ return get(x) == get(y); } bool unite(int x, int y){ x = get(x), y = get(y); if(e[x] < e[y]) swap(x, y); e[x] += e[y]; e[y] = x; return true; } }; void find_roads(int N, int Q, int A[], int B[], int W[]) { vector<pair<pair<int, int>, long long>> edges((N*(N-1))/2); int c = 0; for(int i = 1; i <= N; i++) for(int j = i+1; j <= N; j++) edges[c++] = {{i, j}, get_distance(i, j)}; sort(edges.begin(), edges.end(), [&](pair<pair<int, int>, long long> &a, pair<pair<int, int>, long long> &b){ if(a.s < b.s) return true; return false; }); DSU s; s.init(n); int m = 0; for(int i = 0; i < c; i++){ if(s.same_set(edges[i].f.f, edges[i].f.s)) continue; s.unite(edges[i].f.f, edges[i].f.s); A[m] = edges[i].f.f, B[m] = edges[i].f.s, W[m] = edges[i].s; m++; } return; }

Compilation message (stderr)

citymapping.cpp:6:2: error: 'vi' does not name a type
    6 |  vi e;
      |  ^~
citymapping.cpp: In member function 'void DSU::init(int)':
citymapping.cpp:8:3: error: 'e' was not declared in this scope
    8 |   e = vi(n, -1);
      |   ^
citymapping.cpp:8:7: error: 'vi' was not declared in this scope
    8 |   e = vi(n, -1);
      |       ^~
citymapping.cpp: In member function 'int DSU::get(int)':
citymapping.cpp:12:11: error: 'e' was not declared in this scope
   12 |   return (e[x] < 0 ? x : e[x] = get(e[x]));
      |           ^
citymapping.cpp: In member function 'bool DSU::unite(int, int)':
citymapping.cpp:21:6: error: 'e' was not declared in this scope
   21 |   if(e[x] < e[y])
      |      ^
citymapping.cpp:24:3: error: 'e' was not declared in this scope
   24 |   e[x] += e[y];
      |   ^
citymapping.cpp: In lambda function:
citymapping.cpp:37:8: error: 'struct std::pair<std::pair<int, int>, long long int>' has no member named 's'
   37 |   if(a.s < b.s) return true;
      |        ^
citymapping.cpp:37:14: error: 'struct std::pair<std::pair<int, int>, long long int>' has no member named 's'
   37 |   if(a.s < b.s) return true;
      |              ^
citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:42:9: error: 'n' was not declared in this scope
   42 |  s.init(n);
      |         ^
citymapping.cpp:45:26: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, long long int> >, std::pair<std::pair<int, int>, long long int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, long long int>'} has no member named 'f'
   45 |   if(s.same_set(edges[i].f.f, edges[i].f.s)) continue;
      |                          ^
citymapping.cpp:45:40: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, long long int> >, std::pair<std::pair<int, int>, long long int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, long long int>'} has no member named 'f'
   45 |   if(s.same_set(edges[i].f.f, edges[i].f.s)) continue;
      |                                        ^
citymapping.cpp:46:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, long long int> >, std::pair<std::pair<int, int>, long long int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, long long int>'} has no member named 'f'
   46 |   s.unite(edges[i].f.f, edges[i].f.s);
      |                    ^
citymapping.cpp:46:34: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, long long int> >, std::pair<std::pair<int, int>, long long int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, long long int>'} has no member named 'f'
   46 |   s.unite(edges[i].f.f, edges[i].f.s);
      |                                  ^
citymapping.cpp:47:19: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, long long int> >, std::pair<std::pair<int, int>, long long int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, long long int>'} has no member named 'f'
   47 |   A[m] = edges[i].f.f, B[m] = edges[i].f.s, W[m] = edges[i].s;
      |                   ^
citymapping.cpp:47:40: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, long long int> >, std::pair<std::pair<int, int>, long long int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, long long int>'} has no member named 'f'
   47 |   A[m] = edges[i].f.f, B[m] = edges[i].f.s, W[m] = edges[i].s;
      |                                        ^
citymapping.cpp:47:61: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<std::pair<int, int>, long long int> >, std::pair<std::pair<int, int>, long long int> >::value_type' {aka 'struct std::pair<std::pair<int, int>, long long int>'} has no member named 's'
   47 |   A[m] = edges[i].f.f, B[m] = edges[i].f.s, W[m] = edges[i].s;
      |                                                             ^