Submission #1059601

#TimeUsernameProblemLanguageResultExecution timeMemory
1059601mychecksedadClosing Time (IOI23_closing)C++17
8 / 100
129 ms47040 KiB
#include "closing.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define all(x) x.begin(),x.end() #define ll long long #define ff first #define ss second const int N = 200005; vector<pair<int, ll>> g[N]; void dfs(int v, int p, vector<ll> &D){ for(auto U: g[v]){ int u = U.ff; if(u != p){ D[u] = D[v] + U.ss; dfs(u, v, D); } } } int max_score(int n, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W){ for(int i = 0; i < n; ++i) g[i].clear(); for(int i = 0; i < n - 1; ++i){ g[V[i]].pb({U[i], W[i]}); g[U[i]].pb({V[i], W[i]}); } vector<ll> D1(n), D2(n); dfs(X, X, D1); dfs(Y, Y, D2); vector<array<ll, 3>> A; K *= 2; for(int i = 0; i < n; ++i){ A.pb({min(D1[i], D2[i]) * 2, i, 1}); A.pb({max(D1[i], D2[i]), i, 2}); } int ans = 0; vector<int> used(n); sort(all(A)); for(int i = 0; i < A.size(); ++i){ int v = A[i][1]; if(used[v] == 2){ continue; } if(used[v] == 1){ if(K >= A[i][0] - min(D1[v], D2[v])){ K -= A[i][0] - min(D1[v], D2[v]); used[v] = 2; ++ans; } }else{ if(K >= A[i][0]){ K -= A[i][0]; ans += A[i][2]; used[v] = A[i][2]; } } } return ans; }

Compilation message (stderr)

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |   for(int i = 0; i < A.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...