Submission #1013834

#TimeUsernameProblemLanguageResultExecution timeMemory
1013834vjudge1Tales of seafaring (POI13_mor)C++17
0 / 100
10 ms14684 KiB
#include <bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> // #include <ext/pb_ds/tree_policy.hpp> using namespace std; // using namespace __gnu_pbds; #define int long long #define mod 1000000007 #define base 200003 #define base2 7001 // #define pi acos(-1) #define double long double // #define ordered_set tree<pair<int, int>, null_type, less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> // #define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> #pragma GCC optimize("O3,Ofast,unroll-loops") #pragma GCC target("avx2,sse3,sse4,avx") constexpr int maxn = 300001; const int N = 1 << (int)(ceil(log2(maxn))); int n, depth[maxn], freq[maxn]; vector<int> adj[maxn]; bool vis[maxn]; void dfs(int i, int cnt) { vis[i] = 1; depth[i] = cnt; for (auto j : adj[i]) { if (!vis[j]) dfs(j, cnt + 1); } return; } signed main() { cin.tie(0) -> sync_with_stdio(0); cin >> n; for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; adj[a].push_back(b); adj[b].push_back(a); } dfs (1, 0); for (int i = 2; i <= n; i++) freq[depth[i]]++; sort(depth, depth + maxn); vector<int>v; int mx = 0; for (int i = 0; i < maxn; i++) { if (freq[depth[i]] && depth[i]) v.push_back(freq[depth[i]]); mx = max(mx, freq[depth[i]]); freq[depth[i]] = 0; } int l = 0, r = 3e5; int ans = -1; while (l <= r) { int m = (l + r) / 2; int x = 0; bool flag = 1; for (int i = 0; i < v.size(); i++) { if (v[i] - m - x > 0) { flag = 0; break; } x = (m + x) - v[i]; } if (flag) { r = m - 1; ans = m; } else l = m + 1; } if (ans == -1) { int cnt = 0; for (int i = 0; i < 1e10; i++) { cnt++; } } cout << ans; }

Compilation message (stderr)

mor.cpp: In function 'int main()':
mor.cpp:72:27: 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]
   72 |         for (int i = 0; i < v.size(); i++)
      |                         ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...