Submission #977099

#TimeUsernameProblemLanguageResultExecution timeMemory
977099dubabubaBridges (APIO19_bridges)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int mxn = 2e5 + 10; int par[mxn], ans[mxn], n, m; vector<pair<int, pii>> edges; int parent(int u) { if(par[u] < 0) return u; return par[u] = parent(par[u]); } bool unite(int u, int v) { u = parent(u); v = parent(v); if(u == v) return 0; if(par[u] > par[v]) swap(u, v); par[u] += par[v]; par[v] = u; return 0; } int main() { cin >> n >> m; for(int i = 0; i < m; i++) { int u, v, w; cin >> u >> v >> w; edges.push_back(MP(-w, MP(u, v))); } cin >> q; for(int i = 1; i <= q; i++) { int s, w; cin >> s >> w; edges.push_back(MP(-w, MP(-i, s))); } sort(edges.begin(), edges.end()); memset(par, -1, sizeof par); for(auto p : edges) { if(p.ss.ff > 0) { int w = p.ff; int u = p.ss.ff; int v = p.ss.ss; unite(u, v); } else { int w = p.ff; int i = -p.ss.ff; int s = p.ss.ss; ans[i] = par[parent(s)]; } } for(int i = 1; i <= q; i++) cout << ans[i] << endl; return 0; }

Compilation message (stderr)

bridges.cpp:6:18: error: 'pii' was not declared in this scope
    6 | vector<pair<int, pii>> edges;
      |                  ^~~
bridges.cpp:6:18: error: template argument 2 is invalid
bridges.cpp:6:21: error: template argument 1 is invalid
    6 | vector<pair<int, pii>> edges;
      |                     ^~
bridges.cpp:6:21: error: template argument 2 is invalid
bridges.cpp: In function 'int main()':
bridges.cpp:29:9: error: request for member 'push_back' in 'edges', which is of non-class type 'int'
   29 |   edges.push_back(MP(-w, MP(u, v)));
      |         ^~~~~~~~~
bridges.cpp:29:26: error: 'MP' was not declared in this scope
   29 |   edges.push_back(MP(-w, MP(u, v)));
      |                          ^~
bridges.cpp:29:19: error: 'MP' was not declared in this scope
   29 |   edges.push_back(MP(-w, MP(u, v)));
      |                   ^~
bridges.cpp:32:9: error: 'q' was not declared in this scope
   32 |  cin >> q;
      |         ^
bridges.cpp:36:9: error: request for member 'push_back' in 'edges', which is of non-class type 'int'
   36 |   edges.push_back(MP(-w, MP(-i, s)));
      |         ^~~~~~~~~
bridges.cpp:36:26: error: 'MP' was not declared in this scope
   36 |   edges.push_back(MP(-w, MP(-i, s)));
      |                          ^~
bridges.cpp:36:19: error: 'MP' was not declared in this scope
   36 |   edges.push_back(MP(-w, MP(-i, s)));
      |                   ^~
bridges.cpp:39:13: error: request for member 'begin' in 'edges', which is of non-class type 'int'
   39 |  sort(edges.begin(), edges.end());
      |             ^~~~~
bridges.cpp:39:28: error: request for member 'end' in 'edges', which is of non-class type 'int'
   39 |  sort(edges.begin(), edges.end());
      |                            ^~~
bridges.cpp:42:15: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   42 |  for(auto p : edges) {
      |               ^~~~~
      |               std::begin
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bridges.cpp:1:
/usr/include/c++/10/valarray:1224:5: note: 'std::begin' declared here
 1224 |     begin(const valarray<_Tp>& __va)
      |     ^~~~~
bridges.cpp:42:15: error: 'end' was not declared in this scope; did you mean 'std::end'?
   42 |  for(auto p : edges) {
      |               ^~~~~
      |               std::end
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:95,
                 from bridges.cpp:1:
/usr/include/c++/10/valarray:1244:5: note: 'std::end' declared here
 1244 |     end(const valarray<_Tp>& __va)
      |     ^~~
bridges.cpp:44:8: warning: unused variable 'w' [-Wunused-variable]
   44 |    int w = p.ff;
      |        ^
bridges.cpp:50:8: warning: unused variable 'w' [-Wunused-variable]
   50 |    int w = p.ff;
      |        ^