Submission #1037726

# Submission time Handle Problem Language Result Execution time Memory
1037726 2024-07-29T07:25:13 Z fv3 Closing Time (IOI23_closing) C++17
8 / 100
79 ms 26196 KB
#include "closing.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll INF = 1ll << 60ll;

int max_score(int N, int X, int Y, ll K,
              vector<int> U, vector<int> V, vector<int> W)
{
    vector<vector<pair<int, ll>>> adj(N);
    for (int i = 0; i < U.size(); i++)
    {
        adj[U[i]].push_back({V[i], W[i]});
        adj[V[i]].push_back({U[i], W[i]});
    }

    priority_queue<pair<ll, int>> q;
    q.push({0, X});
    q.push({0, Y});

    vector<int> visited(N);
    vector<ll> dist(N, INF);
    dist[X] = 0;
    dist[Y] = 0;

    int res = 0;
    while (!q.empty())
    {
        int s = q.top().second;
        q.pop();

        if (visited[s]) 
            continue;
        visited[s] = 1;

        K -= dist[s];
        if (K < 0)
            break;
        res++;

        for (auto node : adj[s])
        {
            if (!visited[node.first] && dist[s] + node.second < dist[node.first])
            {
                dist[node.first] = dist[s] + node.second;
                q.push({-dist[node.first], node.first});
            }
        }
    }

    return res;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, ll, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i < U.size(); i++)
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 22356 KB Output is correct
2 Correct 79 ms 26196 KB Output is correct
3 Correct 43 ms 5460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -