# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
632872 | Minindu2006 | Traffic (IOI10_traffic) | C++14 | 12 ms | 23764 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 "traffic.h"
#include <bits/stdc++.h>
using namespace std;
const int MX = 1e6 + 10;
vector<int> adj[MX];
int LocateCentre(int N, int pp[], int S[], int D[])
{
for (int i = 0; i < N - 1; i++)
{
adj[S[i]].push_back(D[i]);
adj[D[i]].push_back(S[i]);
}
set<pair<int, int>> st;
for (int i = 0; i < N; i++)
if (adj[i].size() == 1)
st.insert({pp[i], i});
while(1)
{
if(st.size() == 1)
break;
pair<int, int> cur = *st.begin();
int c = cur.second;
int p = cur.first;
st.erase(st.begin());
int nxt = *adj[c].begin();
adj[c].erase(adj[c].begin());
pp[nxt] += c;
if(adj[nxt].size() == 1)
st.insert({pp[nxt], nxt});
}
return st.begin()->second;
}
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... |