이 제출은 이전 버전의 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<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]].pb(d[i]);
adj[d[i]].pb(s[i]);
}
for(int i=0;i<N-1;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();
int y=0;
for(int i=0;i<sz(adj[b]);i++){
if(!visd[adj[b][i]]){
y=i;
break;
}
}
pp[adj[b][y]]+=a;
vis[adj[b][y]]+=1;
if(sz(adj[adj[b][y]])-vis[adj[b][y]]==1){
q.push(mp(pp[adj[b][y]],adj[b][y]));
visd[adj[b][y]]=true;
}
}
return q.top().se;
}
//Icebear16
컴파일 시 표준 에러 (stderr) 메시지
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:40:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(int i=0;i<sz(adj[b]);i++){
| ^
# | 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... |