Submission #150084

#TimeUsernameProblemLanguageResultExecution timeMemory
150084----MIT합격선---- (#200)Trip to the Galapagos Islands (FXCUP4_island)C++17
0 / 100
168 ms7520 KiB
#include "island.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; pii upa[100000]; int rnk[100000], cnt; int fnd(int x, int t) { return upa[x].second <= t ? x : fnd(upa[x].first, t); } void uni(int x, int y, int t) { x = fnd(x, t), y = fnd(y, t); if (x == y) return; if (rnk[x] < rnk[y]) swap(x, y); upa[y] = {x, t}; if (rnk[x] == rnk[y]) rnk[x]++; } int N, M; void Init(int K, std::vector<int> F, std::vector<int> S, std::vector<int> E){ N = F.size(), M = S.size(); for (int i = 0; i < N; ++i) upa[i] = {i, -1}; for (int i = M - 1; i >= 0; --i) uni(F[S[i]], F[E[i]], i); } int Separate(int A, int B){ int l = 0, r = M; while (l < r) { int m = l + r >> 1; if (fnd(A, m) != fnd(B, m)) r = m; else l = m + 1; } return l; }

Compilation message (stderr)

island.cpp: In function 'int Separate(int, int)':
island.cpp:28:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = l + r >> 1;
           ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...