| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 871018 | Ahmed57 | Paths (RMI21_paths) | C++17 | 2 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,long long>> adj[101],tree[101];
long long ma = -1 , nod = 0;
void dfs(int i,int pr,long long co){
if(ma<co){
ma = co;
nod = i;
}
for(auto j:tree[i]){
if(j.first==pr)continue;
dfs(j.first,i,co+j.second);
}
}
long long all = 0;
bool clea(int i,int pr){
if(i==nod)return 1;
for(int j = 0;j<tree[i].size();j++){
if(tree[i][j].first==pr)continue;
all+=tree[i][j].second;
long long xd = tree[i][j].second;
tree[i][j].second = 0;
bool de = clea(tree[i][j].first,i);
if(de==0){
all-=xd;
tree[i][j].second = xd;
}else{
return 1;
}
}
return 0;
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int n,k;
cin>>n>>k;
for(int i = 0;i<n-1;i++){
int a,b,c;cin>>a>>b>>c;
adj[a].push_back({b,c});
adj[b].push_back({a,c});
}
for(int r = 1;r<=n;r++){
for(int i = 1;i<=n;i++){
tree[i].clear();
for(auto w:adj[i]){
tree[i].push_back(w);
}
}
int e = k;
all = 0;
while(e--){
ma = -1 , nod = 0;
dfs(r,0,0);
clea(r,0);
}
cout<<all<<endl;
}
}
컴파일 시 표준 에러 (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... | ||||
