답안 #1028597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028597 2024-07-20T05:46:29 Z tolbi 꿈 (IOI13_dreaming) C++17
18 / 100
39 ms 8532 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[]) {
#define int long long
    vector<vector<pair<int,int>>> arr(N);
    for (int i = 0; i < M; i++){
        arr[A[i]].push_back({B[i],T[i]});
        arr[B[i]].push_back({A[i],T[i]});
    }
    vector<int> dp(N,-1);
    function<int(int)> f = [&](int src)->int{
        queue<array<int,3>> qu;
        qu.push({src,0,-1});
        int manode = src;
        int mm = 0;
        vector<int> gez;
        while (qu.size()){
            int node = qu.front()[0];
            int w = qu.front()[1];
            int lnode = qu.front()[2];
            qu.pop();
            if (w>mm) manode=node,mm=w;
            for (auto nex : arr[node]){
                if (nex.first==lnode) continue;
                qu.push({nex.first,nex.second+w,node});
            }
        }
        qu.push({manode,0,-1});
        while (qu.size()){
            int node = qu.front()[0];
            int w = qu.front()[1];
            int lnode = qu.front()[2];
            qu.pop();
            dp[node]=w;
            if (dp[node]>dp[manode]) manode=node;
            for (auto nex : arr[node]){
                if (nex.first==lnode) continue;
                qu.push({nex.first,nex.second+w,node});
            }
        }
        int ret = dp[manode];
        qu.push({manode,0,-1});
        while (qu.size()){
            int node = qu.front()[0];
            int w = qu.front()[1];
            int lnode = qu.front()[2];
            qu.pop();
            ret=min(ret,max(dp[node],w));
            for (auto &nex : arr[node]){
                if (nex.first==lnode) continue;
                qu.push({nex.first,nex.second+w,node});
            }
        }
        return ret;
    };
    vector<int> ansarr;
    for (int i = 0; i < N; ++i)
    {
        if (dp[i]==-1) {
            ansarr.push_back(f(i));
        }
    }
    if (ansarr.size()==1) return 0;
    sort(ansarr.begin(), ansarr.end());
    for (int i = 0; i < ansarr.size()-1; i++){
        ansarr[i]+=L;
    }
    sort(ansarr.begin(), ansarr.end());
    return ansarr[ansarr.size()-1]+ansarr[ansarr.size()-2];
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:66:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |     for (int i = 0; i < ansarr.size()-1; i++){
      |                     ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 8532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 8532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 6108 KB Output is correct
2 Correct 19 ms 6364 KB Output is correct
3 Correct 20 ms 6108 KB Output is correct
4 Correct 20 ms 6372 KB Output is correct
5 Correct 17 ms 6104 KB Output is correct
6 Correct 21 ms 7132 KB Output is correct
7 Correct 24 ms 6368 KB Output is correct
8 Correct 19 ms 6192 KB Output is correct
9 Correct 20 ms 6104 KB Output is correct
10 Correct 24 ms 6392 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 11 ms 4684 KB Output is correct
13 Correct 14 ms 4564 KB Output is correct
14 Correct 11 ms 4564 KB Output is correct
15 Correct 11 ms 4564 KB Output is correct
16 Correct 10 ms 4564 KB Output is correct
17 Correct 14 ms 4564 KB Output is correct
18 Correct 11 ms 4560 KB Output is correct
19 Correct 14 ms 4564 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 604 KB Output is correct
23 Correct 11 ms 4564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 8532 KB Output isn't correct
2 Halted 0 ms 0 KB -