Submission #840077

# Submission time Handle Problem Language Result Execution time Memory
840077 2023-08-31T05:57:20 Z normankr07 Closing Time (IOI23_closing) C++17
0 / 100
156 ms 29716 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// CC : g++ -std=gnu++17 -O2 -Wall -pipe -static -o "closing" "grader.cpp" "closing.cpp"

// Subtask 1
vector<vector<pair<int, int>>> adj;
vector<bool> vis;

void DFS_dist(vector<long long> &distx, int u, long long d)
{
    vis[u] = 1;
    distx[u] = d;
    for (auto [v, w] : adj[u])
        if (!vis[v])
            DFS_dist(distx, v, d + w);
}

int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    adj.resize(N, vector<pair<int, int>>());
    for (int i = 0; i < N - 1; i++)
        adj[U[i]].push_back(make_pair(V[i], W[i])), adj[V[i]].push_back(make_pair(U[i], W[i]));

    vector<ll> distx(N), disty(N);
    vis.assign(N, 0);
    DFS_dist(distx, X, 0);
    vis.assign(N, 0);
    DFS_dist(disty, Y, 0);

    distx.insert(distx.end(), disty.begin(), disty.end());
    sort(distx.begin(), distx.end());

    int j = 0, ans = 0;
    ll cc = 0;
    while (cc + distx[j] <= K && j < distx.size())
    {
        cc += distx[j];
        ++ans, ++j;
    }

    return ans;
}

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:38:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     while (cc + distx[j] <= K && j < distx.size())
      |                                  ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 121 ms 26580 KB Output is correct
2 Correct 129 ms 29716 KB Output is correct
3 Incorrect 156 ms 7240 KB 2nd lines differ - on the 1st token, expected: '38', found: '45'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -