Submission #857928

# Submission time Handle Problem Language Result Execution time Memory
857928 2023-10-07T07:26:39 Z Trisanu_Das Village (BOI20_village) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
int adj[11][11];
 
signed main(){
  int n; cin >> n;
  memset(adj, INT_MAX, sizeof(adj));
  for(int i = 0; i < n ; i++) adj[i][i] = 0;
  for(int x = 0; x < n - 1; x++){
    int u, v; cin >> u >> v;
    adj[u][v] = adj[v][u] = 1;
  }
  //Floyd Warshall
  for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
  vector<int> perm, mn, mx;
  int mx_val = INT_MIN, mn_val = INT_MAX;
  for(int i = 0; i < n; i++) perm.push_back(i);
  do{
    int sum = 0; bool flag = true;
    for(int i = 0; i < n; i++){
      if(perm[i] == i){
        flag = false; break;
      }
      sum += adj[i][perm[i]];
      if(!flag) continue;
      if(sum < mn_val){
        mn_val = sum; mn = perm;
      }
      if(sum > mx_val){
        mx_val = sum; mx = perm;
      }
    }
  }while(next_permutation(perm));
  cout << mn_val << ' ' << mx_val << '\n';
  for(int i = 0; i < n; i++) cout << mn[i] + 1 << '\n';
  for(int j = 0; j < n; j++) cout << mx[i] + 1 << '\n';
}

Compilation message

Village.cpp: In function 'int main()':
Village.cpp:35:31: error: no matching function for call to 'next_permutation(std::vector<long long int>&)'
   35 |   }while(next_permutation(perm));
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Village.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:2971:5: note: candidate: 'template<class _BIter> bool std::next_permutation(_BIter, _BIter)'
 2971 |     next_permutation(_BidirectionalIterator __first,
      |     ^~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:2971:5: note:   template argument deduction/substitution failed:
Village.cpp:35:31: note:   candidate expects 2 arguments, 1 provided
   35 |   }while(next_permutation(perm));
      |                               ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Village.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3004:5: note: candidate: 'template<class _BIter, class _Compare> bool std::next_permutation(_BIter, _BIter, _Compare)'
 3004 |     next_permutation(_BidirectionalIterator __first,
      |     ^~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3004:5: note:   template argument deduction/substitution failed:
Village.cpp:35:31: note:   candidate expects 3 arguments, 1 provided
   35 |   }while(next_permutation(perm));
      |                               ^
Village.cpp:38:41: error: 'i' was not declared in this scope
   38 |   for(int j = 0; j < n; j++) cout << mx[i] + 1 << '\n';
      |                                         ^