이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "traffic.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18//change to const int INF=1e18 if causing problem
const ll MOD=998244353;
const ll alt=1e10;
const ll inf=1e9+7;//Precalc is not a bad idea
//#define int ll
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define mod(a) (a+inf)%inf
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
vector<set<int> > adj(100000);
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > > q;
vector<int> vis(100000,0);
vector<bool> visd(100000,false);
int LocateCentre(int N, int pp[], int s[], int d[]){
for(int i=0;i<N-1;i++){
adj[s[i]].insert(d[i]);
adj[d[i]].insert(s[i]);
}
for(int i=0;i<N;i++){
if(adj[i].size()<=1){
q.push(mp(pp[i],i));
visd[i]=true;
}
}
while(sz(q)>1){
int a=q.top().fi,b=q.top().se;
q.pop();
auto y=*adj[b].begin();
pp[y]+=a;
adj[y].erase(b);
if(sz(adj[y])==1){
q.push(mp(pp[y],y));
visd[y]=true;
}
}
return q.top().se;
}
//Icebear16
# | 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... |