Submission #287756

#TimeUsernameProblemLanguageResultExecution timeMemory
287756shrek12357Gondola (IOI14_gondola)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <climits> #include <cmath> #include <fstream> #include <queue> using namespace std; #define MAXN 50 int sz[MAXN], par[MAXN]; int get(int x) { return x == par[x] ? x : par[x] = get(par[x]); } void unite(int a, int b) { a = get(a), b = get(b); if (a == b) { return; } if (sz[a] > sz[b]) { swap(a, b); } par[a] = b; sz[b] += sz[a]; } int main() { int n, q; cin >> n >> q; for (int i = 0; i < MAXN; i++) { sz[i] = 1; par[i] = i; } vector<pair<int, pair<int, int>>> edges; for (int i = 0; i < n - 1; i++) { int a, b, c; cin >> a >> b >> c; edges.push_back({ c * -1,{ a, b } }); } vector<pair<int, int>> queries, ord; for (int i = 0; i < q; i++) { int a, b; cin >> a >> b; queries.push_back(make_pair(a * -1, b)); ord.push_back(make_pair(a*-1, b)); } sort(edges.begin(), edges.end()); sort(queries.begin(), queries.end()); map<pair<int, int>, int> ans; int idx = -1; for (int i = 0; i < q; i++) { int rel = queries[i].first; while (idx < n - 2 && edges[idx + 1].first <= rel) { idx++; unite(edges[idx].second.first, edges[idx].second.second); } ans[queries[i]] = sz[get(queries[i].second)] - 1; //cout << sz[get(queries[i].second)] << endl; } for (int i = 0; i < ord.size(); i++) { cout << ans[ord[i]] << endl; } }

Compilation message (stderr)

gondola.cpp: In function 'int main()':
gondola.cpp:66:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |  for (int i = 0; i < ord.size(); i++) {
      |                  ~~^~~~~~~~~~~~
/tmp/ccXGVCdG.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccASn9zS.o:gondola.cpp:(.text.startup+0x0): first defined here
/tmp/ccXGVCdG.o: In function `main':
grader.cpp:(.text.startup+0xa2): undefined reference to `valid'
grader.cpp:(.text.startup+0xee): undefined reference to `countReplacement'
grader.cpp:(.text.startup+0x112): undefined reference to `replacement'
collect2: error: ld returned 1 exit status