| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 735654 | MODDI | Network (BOI15_net) | C++14 | 7 ms | 12500 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
vi G[500100], leaf;
bool vis[500100];
void dfs(int at, int p){
bool made= false;
vis[at] = true;
for(auto next : G[at]){
if(!vis[next]){
made = true;
dfs(next, at);
}
}
if(!made){
leaf.pb(at);
}
}
int main(){
cin>>n;
for(int i = 1; i < n; i++){
int a, b;
cin>>a>>b;
a--; b--;
G[a].pb(b);
G[b].pb(a);
}
memset(vis, false, sizeof vis);
dfs(0, -1);
// vis[0] = true;
vector<pii> ans;
for(int i = 0; i < leaf.size()-1; i+=2){
ans.pb(mp(leaf[i]+1, leaf[i+1]+1));
}
ans.pb(mp(leaf[leaf.size()-1], 1));
cout<<ans.size()<<endl;
for(auto t : ans)
cout<<t.first<<" "<<t.second<<endl;
return 0;
}
컴파일 시 표준 에러 (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... | ||||
