Language: C++

#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int n;
  cin >> n;
  vector<int> tree(n,0);
  tree.at(0)=1;
  vector<pair<int,int>> bridge;
  for(int i=0; i<n-1; i++){
    int x,y;
    cin >> x >> y;
    if(x >= y){
      bridge.at(i).first=x;
      bridge.at(i).second=y;
    }
    else{
      bridge.at(i).first=y;
      bridge.at(i).second=x;
    }
  }
  sort(pair.begin(),pair.end());
  for(int i=0; i<n-1; i++){
    if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
    else tree.at(bridge.second)=1;
  }
  int count=0;
  vector<int> zyunretu;
  for(int i=0; i<n; i++){
    if(tree.at(i)==1) count++;
  }
  if(count >= n*2/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==0){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i
      count3++;
    }
   if(count <= n*1/3){
    int count2=0;
    int count3=0;
    for(int i=0; i<n; i++){
      if(tree.at(i)==1){
      zyunretu.at(3*count2)=i;
      count2++;
      }
    else{
      zyunretu.at(count3+count3/3+1)=i
      count3++;
    }
    }
 
      
  




Compiler output:
a.cc: In function 'int main()':
a.cc:22:12: error: missing template arguments before '.' token
   22 |   sort(pair.begin(),pair.end());
      |            ^
a.cc:22:25: error: missing template arguments before '.' token
   22 |   sort(pair.begin(),pair.end());
      |                         ^
a.cc:24:23: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
   24 |     if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
      |                       ^~~~~
a.cc:24:49: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   24 |     if(tree.at(bridge.first)==1) tree.at(bridge.second)==0;
      |                                                 ^~~~~~
a.cc:25:25: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
   25 |     else tree.at(bridge.second)=1;
      |                         ^~~~~~
a.cc:41:39: error: expected ';' before 'count3'
   41 |       zyunretu.at(count3+count3/3+1)=i
      |                                       ^
      |                                       ;
   42 |       count3++;
      |       ~~~~~~                           
a.cc:53:39: error: expected ';' before 'count3'
   53 |       zyunretu.at(count3+count3/3+1)=i
      |                                       ^
      |                                       ;
   54 |       count3++;
      |       ~~~~~~                           
a.cc:56:6: error: expected '}' at end of input
   56 |     }
      |      ^
a.cc:44:22: note: to match this '{'
   44 |    if(count <= n*1/3){
      |                      ^
a.cc:56:6: error: expected '}' at end of input
   56 |     }
      |      ^
a.cc:35:27: note: to match this '{'
   35 |     for(int i=0; i<n; i++){
      |                           ^
a.cc:56:6: error: expected '}' at end of input
   56 |     }
      |      ^
a.cc:32:21: note: to match this '{'
   32 |   if(count >= n*2/3){
      |                     ^
a.cc:56:6: error: expected '}' at end of input
   56 |     }
      |      ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^