96702024-02-23 21:45:14999Átvágás (75 pont)cpp17Wrong answer 37/75221ms30572 KiB
#include <bits/stdc++.h>
using namespace std;

int main() 
{
  int n;cin>>n;
  vector<vector<int>> v(n+1);
  for(int i = 0;i<n-1;i++){
    int a,b;cin>>a>>b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  vector<int> dis(n+1,-1);
  int ans1=0;
  queue<int> q;
  int k=1;
  while(v[k].size()!=1)k++;
  q.push(k);
  dis[k]=0;
  while(!q.empty()){
    int node=q.front();
    q.pop();
    if(node!=k&&v[node].size()>2)ans1+=(int)v[node].size()-2;
    for(int i : v[node]){
      if(dis[i]==-1){
        q.push(i);
        dis[i]=dis[node]+1;
      }
    }
  }cout<<ans1<<' '<<2<<endl;
}
SubtaskSumTestVerdictTimeMemory
base37/75
1Accepted0/03ms1812 KiB
2Wrong answer0/03ms2060 KiB
3Wrong answer0/09ms3264 KiB
4Partially correct2/43ms2432 KiB
5Partially correct2/43ms2676 KiB
6Partially correct2/43ms2888 KiB
7Partially correct2/43ms2976 KiB
8Partially correct2/43ms3172 KiB
9Partially correct2/43ms3412 KiB
10Partially correct2/4150ms30184 KiB
11Partially correct2/4171ms29800 KiB
12Partially correct2/4187ms30544 KiB
13Partially correct2/4190ms30572 KiB
14Partially correct2/4201ms29760 KiB
15Partially correct2/4207ms28160 KiB
16Partially correct2/4208ms27664 KiB
17Partially correct2/4203ms27664 KiB
18Partially correct2/5196ms27552 KiB
19Partially correct3/6200ms27684 KiB
20Partially correct3/6221ms27640 KiB
21Partially correct1/23ms4444 KiB