| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 888275 | ash_gamertable | 경주 (Race) (IOI11_race) | C++14 | 1 ms | 2396 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "race.h"
using namespace std;
int ans=1e9;
vector<vector< pair<int,int> > > g;// {node,dist}
vector<int> off;
void dfs(int node,int par,vector<map<int,int> > &hash,int k)
{
for(auto x:g[node])
{
if(x.first==par) continue;
dfs(x.first,node,hash,k);
}
for(auto child:g[node])
{
if(child.first == par) continue;
int off_node = off[node],off_child=off[child.first],edge=child.second,off_used=off_child;
if(hash[node].size()<hash[child.first].size())
{
off_used = off[node];
off[node] = off_child+edge;
edge=0;
swap(hash[node],hash[child.first]);
}
for(auto it=hash[child.first].begin();it!=hash[child.first].end();it++)
{
int dist = it->first + off_used + edge;
int mn_nodes = it->second;
if(hash[node].find(k-dist-off[node])!=hash[node].end())
ans=min(ans,mn_nodes+hash[node][k-dist-off[node]]);
if(hash[node].find(dist-off[node])!=hash[node].end())
{
int v1 = hash[node][dist-off[node]];
hash[node][dist-off[node]] = min(v1,1+mn_nodes);
}
else hash[node][dist-off[node]] = 1+mn_nodes;
}
}
}
int best_path(int N, int K, int H[][2], int L[])
{
int n,k,a,b,wt;
vector<map<int,int> > hash;
n=N;
k=K;
g.resize(n+10);
off.assign(n+10,0);
for(int i=0;i<n-1;i++){
a=H[i][0];
b=H[i][1];
wt=L[i];
a++;b++;
g[a].push_back(make_pair(b,wt));
g[b].push_back(make_pair(a,wt));
}
hash.resize(n+10);
for(int i=1;i<=n;i++) hash[i][0]=1;
dfs(1,0,hash,k);
if(ans==1 || ans==1e9) ans=0;
ans--;
return ans;
}
컴파일 시 표준 에러 (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... | ||||
