# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
578708 | ogibogi2004 | 통행료 (IOI18_highway) | C++14 | 255 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "highway.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN=9e4+6;
vector<pair<int,int> >g[MAXN];
int par[MAXN];
int parEdge[MAXN];
vector<int>order;
void dfs(int u,int p)
{
order.push_back(u);
for(auto xd:g[u])
{
if(xd.first==p)continue;
par[xd.first]=u;
parEdge[xd.first]=xd.second;
dfs(xd.first,u);
order.push_back(u);
}
}
void find_pair(int N, vector<int> U, vector<int> V, int A, int B) {
int M = U.size();
for(int i=0;i<M;i++)
{
g[U[i]].push_back({V[i],i});
g[V[i]].push_back({U[i],i});
}
parEdge[0]=-1;
par[0]=-1;
dfs(0,-1);
int low=0,high=order.size()-1,s,t;
long long dist;
vector<int>w;
for(int i=0;i<M;i++)w.push_back(0);
dist=(long long)ask(w)/A;
while(low<=high)
{
int mid=(low+high)/2;
for(int j=0;j<w.size();j++)w[j]=0;
for(int j=0;j<mid;j++)
{
int x=order[j],y=order[j+1];
if(par[x]==y)w[parEdge[x]]=1;
else w[parEdge[y]]=1;
}
int cntheavy=(long long)(ask(w)-dist*A)/(B-A);
if(cntheavy==dist)
{
s=mid;
high=mid-1;
}
else low=mid+1;
}
low=0;high=order.size()-1;
while(low<=high)
{
int mid=(low+high)/2;
for(int j=0;j<w.size();j++)w[j]=0;
for(int j=mid;j<s;j++)
{
int x=order[j],y=order[j+1];
if(par[x]==y)w[parEdge[x]]=1;
else w[parEdge[y]]=1;
}
int cntheavy=(long long)(ask(w)-dist*A)/(B-A);
if(cntheavy==dist)
{
t=mid;
low=mid+1;
}
else high=mid-1;
}
/*for(auto xd:order)cout<<xd<<" ";
cout<<endl;
cout<<s<<" "<<t<<endl;
cout<<order[s]<<" "<<order[t]<<endl;*/
answer(order[s],order[t]);
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |