Submission #1037893

#TimeUsernameProblemLanguageResultExecution timeMemory
1037893ZicrusClosing Time (IOI23_closing)C++17
8 / 100
94 ms28964 KiB
#include <bits/stdc++.h> #include "closing.h" using namespace std; typedef long long ll; int max_score(int n, int x, int y, ll k, vector<int> u, vector<int> v, vector<int> w) { priority_queue<pair<ll, ll>> finalQ; vector<vector<pair<ll, ll>>> adj(n); for (int i = 0; i < w.size(); i++) { adj[u[i]].push_back({-w[i], v[i]}); adj[v[i]].push_back({-w[i], u[i]}); } vector<ll> distX(n, 1ll << 62ll), distY(n, 1ll << 62ll); vector<bool> vstX(n), vstY(n); priority_queue<pair<ll, ll>> q; distX[x] = distY[y] = 0; q.push({0, x}); while (!q.empty()) { ll node = q.top().second; q.pop(); if (vstX[node]) continue; vstX[node] = true; for (auto &e : adj[node]) { distX[e.second] = min(distX[e.second], distX[node] - e.first); q.push({-distX[e.second], e.second}); } } q.push({0, y}); while (!q.empty()) { ll node = q.top().second; q.pop(); if (vstY[node]) continue; vstY[node] = true; for (auto &e : adj[node]) { distY[e.second] = min(distY[e.second], distY[node] - e.first); q.push({-distY[e.second], e.second}); } } for (int i = 0; i < n; i++) { finalQ.push({-min(distX[i], distY[i]), i}); } ll res = 0; while (!finalQ.empty()) { ll dist = -finalQ.top().first; finalQ.pop(); if (dist > k) return res; k -= dist; res++; } return res; }

Compilation message (stderr)

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