이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
const int N=2e5+99;
int n,m,S,T,par[N],mark[N],f[N];
ll A,B,ST;
vector<int> w,vec,U,V;
vector<pair<int,int>> g[N];
void reset(int x){
fill(all(w),x);
}
int Root(){
int l=0,r=n;
while(l+1<r){
int mid=(l+r)>>1;
reset(0);
f(i,0,mid) w[i]=1;
if(ST*A<ask(w)){
r=mid;
}
else{
l=mid;
}
}
return U[l];
}
int find(int x){
fill(mark,mark+N,0);
vector<int> vec;
vec.pb(x);
mark[x]=1;
f(i,0,vec.size()){
int u=vec[i];
for(auto [v,id] : g[u]){
if(mark[v]==0){
vec.pb(v);
f[v]=id;
mark[v]=1;
}
}
}
int l=1,r=n;
while(l+1<r){
int mid=(l+r)>>1;
reset(1);
f(i,1,mid){
w[f[vec[i]]]=0;
}
if(ask(w)==A*ST){
r=mid;
}
else{
l=mid;
}
}
return vec[l];
}
void find_pair(int _n,vector<int> _U,vector<int> _V,int _A,int _B){
U=_U,V=_V;
n=_n,m=U.size(),A=_A,B=_B;
f(i,0,m){
g[U[i]].pb({V[i],i});
g[V[i]].pb({U[i],i});
}
w.resize(m);
ST=ask(w)/A;
int rt=Root();
S=find(rt);
T=find(S);
answer(S,T);
}
/*
3 2 1 2 1 2
0 1
1 2
*/
컴파일 시 표준 에러 (stderr) 메시지
highway.cpp: In function 'int find(int)':
highway.cpp:9:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
9 | #define f(i,a,b) for(int i=a;i<b;i++)
......
54 | f(i,0,vec.size()){
| ~~~~~~~~~~~~~~
highway.cpp:54:3: note: in expansion of macro 'f'
54 | f(i,0,vec.size()){
| ^
highway.cpp:56:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
56 | for(auto [v,id] : g[u]){
| ^
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |