# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
864317 | raphaelp | Sightseeing (NOI14_sightseeing) | C++14 | 2079 ms | 102724 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int UF[500000];
int Rank[500000];
int num = 0;
int find(int x)
{
return (x == UF[x]) ? x : (UF[x] = find(UF[x]));
}
bool merge(int a, int b)
{
a = find(a);
b = find(b);
if (a == b)
return false;
if (Rank[b] > Rank[a])
swap(a, b);
UF[b] = a;
if (Rank[b] == Rank[a])
Rank[a]++;
num++;
return true;
}
void rec(int x, int w, vector<vector<pair<int, int>>> &Tree, vector<int> &occ, vector<int> &Querries)
{
occ[x] = 1;
if (Querries[x] == 1)
Querries[x] = w;
for (int i = 0; i < Tree[x].size(); i++)
{
if (occ[Tree[x][i].first] == 1)
continue;
rec(Tree[x][i].first, min(w, Tree[x][i].second), Tree, occ, Querries);
}
}
void linsort(vector<tuple<int, int, int>> &Tab)
{
vector<vector<tuple<int, int, int>>> temp(100003);
for (int i = 0; i < Tab.size(); i++)
{
temp[get<0>(Tab[i])].push_back(Tab[i]);
}
Tab.clear();
for (int i = 0; i < 100003; i++)
{
for (int j = 0; j < temp[i].size(); j++)
{
Tab.push_back(temp[i][j]);
}
}
}
int main()
{
int V, E, Q;
cin >> V >> E >> Q;
for (int i = 0; i < V; i++)
{
UF[i] = i;
Rank[i] = 0;
}
vector<tuple<int, int, int>> Tab;
for (int i = 0; i < E; i++)
{
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
Tab.push_back({c, a, b});
}
linsort(Tab);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |