Submission #915098

#TimeUsernameProblemLanguageResultExecution timeMemory
915098AbitoVillage (BOI20_village)C++14
12 / 100
1014 ms2652 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define F first #define S second #define pb push_back #define ppb pop_back #define ep insert #define endl '\n' #define elif else if #define pow pwr #define sqrt sqrtt #define int long long #define ll long long #define y1 YONE #define free freeee #define lcm llcm /* ⠄⠄⠄⠄⢠⣿⣿⣿⣿⣿⢻⣿⣿⣿⣿⣿⣿⣿⣿⣯⢻⣿⣿⣿⣿⣆⠄⠄⠄ ⠄⠄⣼⢀⣿⣿⣿⣿⣏⡏⠄⠹⣿⣿⣿⣿⣿⣿⣿⣿⣧⢻⣿⣿⣿⣿⡆⠄⠄ ⠄⠄⡟⣼⣿⣿⣿⣿⣿⠄⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⣿⣇⢻⣿⣿⣿⣿⠄⠄ ⠄⢰⠃⣿⣿⠿⣿⣿⣿⠄⠄⠄⠄⠄⠄⠙⠿⣿⣿⣿⣿⣿⠄⢿⣿⣿⣿⡄⠄ ⠄⢸⢠⣿⣿⣧⡙⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠈⠛⢿⣿⣿⡇⠸⣿⡿⣸⡇⠄ ⠄⠈⡆⣿⣿⣿⣿⣦⡙⠳⠄⠄⠄⠄⠄⠄⢀⣠⣤⣀⣈⠙⠃⠄⠿⢇⣿⡇⠄ ⠄⠄⡇⢿⣿⣿⣿⣿⡇⠄⠄⠄⠄⠄⣠⣶⣿⣿⣿⣿⣿⣿⣷⣆⡀⣼⣿⡇⠄ ⠄⠄⢹⡘⣿⣿⣿⢿⣷⡀⠄⢀⣴⣾⣟⠉⠉⠉⠉⣽⣿⣿⣿⣿⠇⢹⣿⠃⠄ ⠄⠄⠄⢷⡘⢿⣿⣎⢻⣷⠰⣿⣿⣿⣿⣦⣀⣀⣴⣿⣿⣿⠟⢫⡾⢸⡟⠄. ⠄⠄⠄⠄⠻⣦⡙⠿⣧⠙⢷⠙⠻⠿⢿⡿⠿⠿⠛⠋⠉⠄⠂⠘⠁⠞⠄⠄⠄ ⠄⠄⠄⠄⠄⠈⠙⠑⣠⣤⣴⡖⠄⠿⣋⣉⣉⡁⠄⢾⣦⠄⠄⠄⠄⠄⠄⠄⠄ */ typedef unsigned long long ull; using namespace std; const int N=1e3+5; int dis[N][N],n; vector<int> adj[N]; void dfs(int x,int p,int s,int d){ dis[s][x]=d; for (auto u:adj[x]) if (u!=p) dfs(u,x,s,d+1); return; } int32_t main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); cin>>n; for (int i=1;i<n;i++){ int x,y; cin>>x>>y; adj[x].pb(y); adj[y].pb(x); } for (int i=1;i<=n;i++) dfs(i,0,i,0); int mn=LLONG_MAX,mx=LLONG_MIN; vector<int> v1,v2,v; for (int i=1;i<=n;i++) v.pb(i); do{ bool ok=true; for (int i=0;i<v.size();i++) ok&=(v[i]!=i+1); if (!ok) continue; int c=0; for (int i=0;i<v.size();i++) c+=dis[i+1][v[i]]; if (c<mn){ mn=c; v1=v; } if (c>mx){ mx=c; v2=v; } }while(next_permutation(v.begin(),v.end())); cout<<mn<<' '<<mx<<endl; for (auto u:v1) cout<<u<<' ';cout<<endl; for (auto u:v2) cout<<u<<' ';cout<<endl; return 0; }

Compilation message (stderr)

Village.cpp: In function 'int32_t main()':
Village.cpp:55:23: 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]
   55 |         for (int i=0;i<v.size();i++) ok&=(v[i]!=i+1);
      |                      ~^~~~~~~~~
Village.cpp:58:23: 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]
   58 |         for (int i=0;i<v.size();i++) c+=dis[i+1][v[i]];
      |                      ~^~~~~~~~~
Village.cpp:69:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   69 |     for (auto u:v1) cout<<u<<' ';cout<<endl;
      |     ^~~
Village.cpp:69:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   69 |     for (auto u:v1) cout<<u<<' ';cout<<endl;
      |                                  ^~~~
Village.cpp:70:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   70 |     for (auto u:v2) cout<<u<<' ';cout<<endl;
      |     ^~~
Village.cpp:70:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   70 |     for (auto u:v2) cout<<u<<' ';cout<<endl;
      |                                  ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...