답안 #941349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
941349 2024-03-08T15:30:27 Z VinhLuu 꿈 (IOI13_dreaming) C++17
컴파일 오류
0 ms 0 KB
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include"dreaming.h"
#include <bits/stdc++.h>
//#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(lmao) lmao.begin(), lmao.end()

using namespace std;

typedef pair<int,int> pii;
typedef tuple<int,int,int> tp;
const int N = 3e5 + 5;
//const int oo = 1e18;
//const int mod = 1e9 + 7;

int n, m, l, mx, d[5][N], tmp, vr, dk, k, e;
vector<pii> p[N];
bool fl[N];

void dfs(int t, int u,int v){
    if(d[t][u] > d[t][mx]) mx = u;
    for(auto [j, w] : p[u]){
        if(j == v) continue;
        d[t][j] = d[t][u] + w;
        dfs(t, j, u);
    }
}

void sol(int u,int v){
    if(d[1][u] + d[2][u] == dk && max(d[1][u], d[2][u]) < tmp){
        tmp = max(d[1][u], d[2][u]);
    }
    fl[u] = true;
    for(auto [j, w] : p[u]){
        if(j == v) continue;
        sol(j, u);
    }
}

int travelTime(int NT,int M,int L, vector<int> A,vector<int> B,vector<int> T){
    n = NT, m = M, l = L;
    for(int i = 0; i < m; i ++){
        A[i]++;
        B[i]++;
        p[A[i]].pb({B[i], T[i]});
        p[B[i]].pb({A[i], T[i]});
    }
    vector<int> c;
    for(int i = 1; i <= n; i ++){
        if(!fl[i]){
            mx = 0;
            dfs(0, i, 0);
            k = mx;
            mx = 0;
            dfs(1, k, 0);
            dk = d[1][mx];
            e = mx;
            dfs(2, e, 0);
            tmp = 1e9;
            sol(k, 0);
            c.pb(tmp);
        }
    }
    sort(all(c), greater<int>());
    int ans = 0;
    tmp = 0;
    for(int i = 1; i <= c.size() - 1; i ++){
        ans = max({ans, c[0] + c[i] + l, tmp + l + c[i]});
        tmp = max(tmp, l + c[i]);
    }
    return ans;
}

//#define LOCAL

#ifdef LOCAL

int A[N], B[N], T[N], NT, M, L;

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    #define task "v"
    if(fopen(task ".inp","r")){
        freopen(task ".inp","r",stdin);
        freopen(task ".out","w",stdout);
    }

    cin >> NT >> M >> L;
    for(int i = 0; i < M; i ++){
        cin >> A[i] >> B[i] >> T[i];
    }
    cout << travelTime(NT, M, L, A, B, T) << "\n";
}


#endif // LOCAL

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
dreaming.cpp:73:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for(int i = 1; i <= c.size() - 1; i ++){
      |                    ~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccBwQ4Jh.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status