답안 #840073

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
840073 2023-08-31T05:37:38 Z normankr07 봉쇄 시간 (IOI23_closing) C++17
0 / 100
1000 ms 2097152 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
const int MAXN = 1e6;
vector<pair<int, int>> adj[MAXN];
ll dist[MAXN];

void DFS_dist(int u, int par, int d)
{
    dist[u] = d;
    for (auto &[v, w] : adj[u])
    {
        if (v == par)
            continue;
        DFS_dist(v, u, 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)
{

    for (int i = 0; i < N - 1; i++)
    {
        adj[i].clear();
        memset(dist, 0, sizeof(dist));
    }
    for (int i = 0; i < N; i++)
    {
        adj[U[i]].push_back({V[i], W[i]});
        adj[V[i]].push_back({U[i], W[i]});
    }

    DFS_dist(X, X, 0);
    vector<ll> xdist(dist, dist + N);
    DFS_dist(Y, Y, 0);
    vector<ll> ydist(dist, dist + N);

    sort(xdist.begin(), xdist.end());
    sort(ydist.begin(), ydist.end());

    vector<ll> dist;
    merge(xdist.begin(), xdist.end(), ydist.begin(), ydist.end(), back_inserter(dist));

    int j = 0, ans = 0;
    ll cst = 0;
    for (; cst + dist[j] <= K && j < dist.size(); ans++, j++)
        cst += dist[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:52:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for (; cst + dist[j] <= K && j < dist.size(); ans++, j++)
      |                                  ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 975 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1075 ms 36300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 63884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 63884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 63884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 975 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 975 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 975 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 975 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 975 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -