제출 #79557

#제출 시각아이디문제언어결과실행 시간메모리
79557FutymyCloneNetwork (BOI15_net)C++14
0 / 100
2 ms552 KiB
#include <bits/stdc++.h>

using namespace std;

const int N = 5e5 + 5;

int deg[N], n;
vector <int> vec;

int main(){
    scanf("%d", &n);
    for (int i = 1; i <= n - 1; i++) {
        int u, v; scanf("%d %d", &u, &v);
        deg[u]++; deg[v]++;
    }

    for (int i = 1; i <= n; i++) if (deg[i] == 1) vec.push_back(i);
    printf("%d\n", ((int)vec.size() + 1) / 2);
    for (int i = 0; i < ((int)vec.size() + 1) / 2; i++) printf("%d %d\n", vec[i], vec[i + vec.size() / 2]);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

net.cpp: In function 'int main()':
net.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
net.cpp:13:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int u, v; scanf("%d %d", &u, &v);
                   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...