답안 #939072

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
939072 2024-03-06T05:16:33 Z ezzzay Network (BOI15_net) C++14
0 / 100
1 ms 500 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
const int N=3e3+5;
bool vis[N];
vector<int>v[N];
vector<pair<int,int>>rts;
vector<int>vec;
signed main(){
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
        rts.pb({a,b});
    }
    for(int i=1;i<=n;i++){
        if(v[i].size()==1)vec.pb(i);
    }
    cout<<vec.size()/2+vec.size()%2<<endl;
    for(int i=0;i<vec.size()-1;i+=2){
        cout<<vec[i]<<" "<<vec[i+1]<<endl;
    }
    if(vec.size()%2==0)return 0;
    for(auto a:v[vec[vec.size()-1]]){
        vis[a]=1;
    }
    for(int i=1;i<=n;i++){
        if(vis[i]==0){
            cout<<i<<" "<<vec[vec.size()-1];
            return 0;
        }
    }
    
}

Compilation message

net.cpp: In function 'int main()':
net.cpp:26:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<vec.size()-1;i+=2){
      |                 ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Incorrect 1 ms 348 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Incorrect 1 ms 348 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 500 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Incorrect 1 ms 348 KB Breaking single line is causing network to disconnect.
11 Halted 0 ms 0 KB -