답안 #996517

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
996517 2024-06-10T18:15:26 Z 3lektra 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define vi vector<int>
#define vc vector
#define pi pair<int,int>
using namespace std;

vc<vc<pi>> edg; // Edges, aka the corridors coming out from each room
vc<pi> dis; // The two minimum distances found between 2 nodes. The fastest route will just be used to calculate the second fastest, which is the oke that will be used to obtain the other distances
int fpath = -1e9-7; // Fastest path
int u, c; // Amazing the amount of situations when a node and a cost can be useful

void dijkstra(vi p){ // First Node
    priority_queue<pi> tv; // To Visit, not TeleVision or To Vandalize
    for(int i : p){
        tv.push({0,i});
        dis[i].first = 0;}
    while(!tv.empty()){
        u = tv.top().second; // The node being explored right now
        c = tv.top().first; // The cost to get to u
        tv.pop();
        
        if(dis[u].second>c){continue;} // If this path is worse then why bother
        if(u == 0){
            fpath = max(fpath, c);
            continue;}
            
        for(pi p : edg[u]){     // p.first = cost, p.second = node the path leads to
            if (p.first + c > dis[p.second].second){    // If this is path you've found is fastest than the second fastest one...
                if (p.first + c > dis[p.second].first){     // And than the fastest one...
                    dis[p.second].second = dis[p.second].first;     // Then the previously fastest one becomes the second fastest one...
                    dis[p.second].first = p.first + c;}     // This new path becomes the fastest!
                    
                else{ // But if it's not fastest than the fastest one...
                    dis[p.second].second = p.first + c;}
                    
                tv.push({dis[p.second].second, p.second});
            

            }
        }
    }
}



int travel_plan(int n, int m, int (*) 2 r, int l, int k, int p){
    edg = vc<vc<pi>>(n);
    for(int i = 0; i < m; i++){
        edg[r[i][0]].push_back({-l[i],r[i][1]});
        edg[r[i][1]].push_back({-l[i],r[i][0]});}
    
    dis = vc<pi>(n,{-1e9-7,-1e9-7});  
        
    dijkstra(p);

    //for(pi i : dis){cout << i.first << ' ' << i.second << " -- ";}
    //cout << -fpath;
return -fpath;}

return 0;}


Compilation message

crocodile.cpp:46:39: error: expected ',' or '...' before numeric constant
   46 | int travel_plan(int n, int m, int (*) 2 r, int l, int k, int p){
      |                                       ^
crocodile.cpp: In function 'int travel_plan(int, int, int*)':
crocodile.cpp:49:13: error: 'r' was not declared in this scope
   49 |         edg[r[i][0]].push_back({-l[i],r[i][1]});
      |             ^
crocodile.cpp:49:34: error: 'l' was not declared in this scope
   49 |         edg[r[i][0]].push_back({-l[i],r[i][1]});
      |                                  ^
crocodile.cpp:54:14: error: 'p' was not declared in this scope
   54 |     dijkstra(p);
      |              ^
crocodile.cpp: At global scope:
crocodile.cpp:60:1: error: expected unqualified-id before 'return'
   60 | return 0;}
      | ^~~~~~
crocodile.cpp:60:10: error: expected declaration before '}' token
   60 | return 0;}
      |          ^