답안 #747584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747584 2023-05-24T11:09:39 Z coding_snorlax 꿈 (IOI13_dreaming) C++14
컴파일 오류
0 ms 0 KB
//#include<bits/stdc++.h>
#include "dreaming.h"
using namespace std;
using ll = long long int;
ll dis1[200002] = {0};
ll dis2[200002] = {0};
vector<int> vis_node;
ll vis[200002] = {0};
ll Process[200002] = {0};
int cost;
void init(){
    for(int i:vis_node){
        vis[i]=0;
        dis2[i]=0;
        Process[i] = 1;
    }
    //vis_node.clear();
}
vector<pair<ll,ll>> G[100002];
int dfs_1(int node,int father,int weight){
    //cout << node << " ";
    vis_node.push_back(node);
    vis[node]=1;
    dis1[node] = dis1[father] + weight;
    for(auto i:G[node]){
        if(!vis[i.first]) dfs_1(i.first,node,i.second);
    }
}
int dfs_2(int node,int father,int weight){
    vis_node.push_back(node);
    vis[node]=1;
    dis2[node] = dis2[father] + weight;
    for(auto i:G[node]){
        if(!vis[i.first]) dfs_2(i.first,node,i.second);
    }
}
 
ll Node_f(int node){
    init();
    dfs_1(node,node,0);
    int Max = 0;
    int Max_place = 0;
    for(int i:vis_node){
        if(Max < dis1[i]){
            Max = dis1[i];
            Max_place = i;
        }
    }
    init();
    dfs_2(Max_place,Max_place,0);
    for(int i:vis_node){
        dis1[i] = dis2[i];
    }
    Max = 0; Max_place = 0;
    for(int i:vis_node){
        if(Max < dis1[i]){
            Max = dis1[i];
            Max_place = i;
        }
    }
    init();
    dfs_2(Max_place,Max_place,0);
    ll answer = 1500000000;
    for(int i:vis_node){
        dis1[i] = max(dis1[i],dis2[i]);
        answer = min(dis1[i],answer);
    }
    //cout << endl;
 
    return answer;
}
int travelTime(int N,int M,int L,vector<int> A,vector<int> B,vector<int> T){
    for(int i=0;i<M;i++){
        G[A[i]].push_back(make_pair(B[i],T[i]));
        G[B[i]].push_back(make_pair(A[i],T[i]));
    }
    cost = L;
    vector<int> List;
    for(int i=0;i<M;i++){
        if(!Process[i]){
            List.push_back(Node_f(i));
            //cout << i << " " << Node_f(i) << endl;
            //for(int j:vis_node) cout << j << " ";
            //cout << endl;
            vis_node.clear();
        }
    }
    sort(List.begin(),List.end());
    int answer = List.back();
    List.pop_back();
    return answer+List.back()+L;
}

Compilation message

dreaming.cpp:7:1: error: 'vector' does not name a type
    7 | vector<int> vis_node;
      | ^~~~~~
dreaming.cpp: In function 'void init()':
dreaming.cpp:12:15: error: 'vis_node' was not declared in this scope
   12 |     for(int i:vis_node){
      |               ^~~~~~~~
dreaming.cpp: At global scope:
dreaming.cpp:19:1: error: 'vector' does not name a type
   19 | vector<pair<ll,ll>> G[100002];
      | ^~~~~~
dreaming.cpp: In function 'int dfs_1(int, int, int)':
dreaming.cpp:22:5: error: 'vis_node' was not declared in this scope
   22 |     vis_node.push_back(node);
      |     ^~~~~~~~
dreaming.cpp:25:16: error: 'G' was not declared in this scope
   25 |     for(auto i:G[node]){
      |                ^
dreaming.cpp:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
   28 | }
      | ^
dreaming.cpp: In function 'int dfs_2(int, int, int)':
dreaming.cpp:30:5: error: 'vis_node' was not declared in this scope
   30 |     vis_node.push_back(node);
      |     ^~~~~~~~
dreaming.cpp:33:16: error: 'G' was not declared in this scope
   33 |     for(auto i:G[node]){
      |                ^
dreaming.cpp:36:1: warning: no return statement in function returning non-void [-Wreturn-type]
   36 | }
      | ^
dreaming.cpp: In function 'll Node_f(int)':
dreaming.cpp:43:15: error: 'vis_node' was not declared in this scope
   43 |     for(int i:vis_node){
      |               ^~~~~~~~
dreaming.cpp:51:15: error: 'vis_node' was not declared in this scope
   51 |     for(int i:vis_node){
      |               ^~~~~~~~
dreaming.cpp:55:15: error: 'vis_node' was not declared in this scope
   55 |     for(int i:vis_node){
      |               ^~~~~~~~
dreaming.cpp:64:15: error: 'vis_node' was not declared in this scope
   64 |     for(int i:vis_node){
      |               ^~~~~~~~
dreaming.cpp:65:19: error: 'max' was not declared in this scope; did you mean 'Max'?
   65 |         dis1[i] = max(dis1[i],dis2[i]);
      |                   ^~~
      |                   Max
dreaming.cpp:66:18: error: 'min' was not declared in this scope
   66 |         answer = min(dis1[i],answer);
      |                  ^~~
dreaming.cpp: At global scope:
dreaming.cpp:72:34: error: 'vector' has not been declared
   72 | int travelTime(int N,int M,int L,vector<int> A,vector<int> B,vector<int> T){
      |                                  ^~~~~~
dreaming.cpp:72:40: error: expected ',' or '...' before '<' token
   72 | int travelTime(int N,int M,int L,vector<int> A,vector<int> B,vector<int> T){
      |                                        ^
dreaming.cpp: In function 'int travelTime(int, int, int, int)':
dreaming.cpp:74:9: error: 'G' was not declared in this scope
   74 |         G[A[i]].push_back(make_pair(B[i],T[i]));
      |         ^
dreaming.cpp:74:11: error: 'A' was not declared in this scope
   74 |         G[A[i]].push_back(make_pair(B[i],T[i]));
      |           ^
dreaming.cpp:74:37: error: 'B' was not declared in this scope
   74 |         G[A[i]].push_back(make_pair(B[i],T[i]));
      |                                     ^
dreaming.cpp:74:42: error: 'T' was not declared in this scope
   74 |         G[A[i]].push_back(make_pair(B[i],T[i]));
      |                                          ^
dreaming.cpp:74:27: error: 'make_pair' was not declared in this scope
   74 |         G[A[i]].push_back(make_pair(B[i],T[i]));
      |                           ^~~~~~~~~
dreaming.cpp:3:1: note: 'std::make_pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
    2 | #include "dreaming.h"
  +++ |+#include <utility>
    3 | using namespace std;
dreaming.cpp:78:5: error: 'vector' was not declared in this scope
   78 |     vector<int> List;
      |     ^~~~~~
dreaming.cpp:3:1: note: 'std::vector' is defined in header '<vector>'; did you forget to '#include <vector>'?
    2 | #include "dreaming.h"
  +++ |+#include <vector>
    3 | using namespace std;
dreaming.cpp:78:12: error: expected primary-expression before 'int'
   78 |     vector<int> List;
      |            ^~~
dreaming.cpp:81:13: error: 'List' was not declared in this scope
   81 |             List.push_back(Node_f(i));
      |             ^~~~
dreaming.cpp:85:13: error: 'vis_node' was not declared in this scope
   85 |             vis_node.clear();
      |             ^~~~~~~~
dreaming.cpp:88:10: error: 'List' was not declared in this scope
   88 |     sort(List.begin(),List.end());
      |          ^~~~
dreaming.cpp:88:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   88 |     sort(List.begin(),List.end());
      |     ^~~~
      |     short