답안 #741620

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741620 2023-05-14T13:20:22 Z vjudge1 꿈 (IOI13_dreaming) C++17
컴파일 오류
0 ms 0 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
int travelTime(int N, int M, int L, vector<int> A, vector<int> B, vector<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;
}

int main() {
    cout << "AS";
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, std::vector<int>, std::vector<int>, std::vector<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++) {
      |                         ~~^~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccJxyILh.o: in function `main':
dreaming.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccFnFWJk.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccFnFWJk.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status