답안 #741625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741625 2023-05-14T13:25:22 Z vjudge1 꿈 (IOI13_dreaming) C++17
0 / 100
37 ms 9048 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    priority_queue<pair<int, int> > pq;
    vector<vector<pair<int, int> > > ng(N);
    for (int i = 0; i < M; i++) {
        ng[A[i]].push_back(make_pair(B[i], T[i]));
        ng[B[i]].push_back(make_pair(A[i], T[i]));
    }
    vector<int> zeros(N);
    vector<int> nc(N);
    for (int i = 0; i < N; i++) {
        nc[i] = ng[i].size();
        if (nc[i] == 1) {
            pq.push(make_pair(0, i));
        } else if (nc[i] == 0) {
            zeros[i] = true;
        }
    }
    vector<int> vis(N);
    vector<int> dis(N);
    while (!pq.empty()) {
        int s = pq.top().second;
        pq.pop();
        if (nc[s] == 0)continue;
        vis[s] = true;
        for (int i = 0; i < ng[s].size(); i++) {
            int neg = ng[s][i].first;
            int ds = ng[s][i].second;
            if (vis[neg])continue;
            dis[neg] = max(dis[neg], dis[s] + ds);
            if (nc[neg] == 2) {
                pq.push(make_pair(-dis[neg], neg));
            } else if (nc[neg] == 1) {
                zeros[neg] = 1;
            }
            nc[neg]--;
        }
    }
    int rez = 0;
    vector<int> vals;
    for (int i = 0; i < N; i++) {
        if (!zeros[i])continue;
        vals.push_back(dis[i]);
    }
    sort(vals.begin(), vals.end());
    reverse(vals.begin(), vals.end());
    rez = vals[0] + vals[1] + L;
    if (vals.size() > 2) rez = max(rez, vals[1] + vals[2] + L + L);
    return rez;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:28:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int>, std::allocator<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int i = 0; i < ng[s].size(); i++) {
      |                         ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 9048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 9048 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 7692 KB Output is correct
2 Correct 29 ms 7620 KB Output is correct
3 Correct 29 ms 7628 KB Output is correct
4 Correct 31 ms 7732 KB Output is correct
5 Correct 29 ms 7592 KB Output is correct
6 Correct 32 ms 8396 KB Output is correct
7 Correct 31 ms 8012 KB Output is correct
8 Correct 29 ms 7508 KB Output is correct
9 Correct 29 ms 7472 KB Output is correct
10 Correct 30 ms 7880 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 5 ms 4816 KB Output is correct
13 Correct 5 ms 4944 KB Output is correct
14 Correct 5 ms 4816 KB Output is correct
15 Correct 5 ms 4816 KB Output is correct
16 Correct 5 ms 4816 KB Output is correct
17 Correct 4 ms 4816 KB Output is correct
18 Correct 5 ms 4944 KB Output is correct
19 Correct 5 ms 4816 KB Output is correct
20 Incorrect 1 ms 308 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 9048 KB Output isn't correct
2 Halted 0 ms 0 KB -