Submission #955974

#TimeUsernameProblemLanguageResultExecution timeMemory
955974shezittPapričice (COCI20_papricice)C++17
15 / 110
19 ms468 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; #define int ll #define fore(i, a, b) for(int i=a; i<b; ++i) #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define pb(x) push_back(x) #define vi vector<int> const int N = 205; vi adj[N]; int n; int taken[N]; int dfs(int x, int prev=-1){ int tam = 1; for(int child : adj[x]){ if(child == prev) continue; tam += dfs(child, x); } if(taken[x]){ taken[x] = tam; tam = 0; } return tam; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; if(n <= 200){ fore(i, 0, n-1){ int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } int ans = 1e9; taken[1] = 1; for(int i=2; i<=n; ++i){ for(int j=i+1; j<=n; ++j){ taken[1] = taken[i] = taken[j] = 1; dfs(1); ans = min(ans, max({taken[1],taken[i],taken[j]}) - min({taken[1],taken[i],taken[j]})); taken[1] = taken[i] = taken[j] = 0; } } cout << ans; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...