Submission #305991

# Submission time Handle Problem Language Result Execution time Memory
305991 2020-09-24T09:05:45 Z juggernaut Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include"dreaming.h"
//#include"grader.c"
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
vector<pair<int,int>>g[100005];
int path[105],mn,idd;
bool vis[105];
void dfs(int v,int p,int depth,int glob){
    path[glob]=max(depth,path[glob]);
    mn=max(mn,depth);
    for(auto to:g[v])
    if(to.fr!=p)
        dfs(to.fr,v,depth+to.sc,glob);
}
void go(int v,int p){
    vis[v]=1;
    mn=min(mn,path[v]);
    if(path[v]<mn){
        mn=path[v];
        idd=v;
    }
    for(auto to:g[v])
    if(to.fr!=p)
        go(to.fr,v);
}
int travelTime(int n,int m,int l,int x[],int y[],int z[]){
    for(int i=0;i<m;i++){
        g[x[i]].push_back({y[i],z[i]});
        g[y[i]].push_back({x[i],z[i]});
    }
    for(i=0;i<n;i++)dfs(i,i,0,i);
    stack<int>st;
    for(i=0;i<n;i++)if(!vis[i]){
        mn=2e9;
        go(i,i);
        st.push(idd);
    }
    if(st.size()!=2)exit(1);
    int x=st.top();
    st.pop();
    int y=st.top();
    st.pop();
    g[x].push_back(y);
    g[y].push_back(x);
    mn=0;
    for(i=0;i<n;i++)dfs(i,i,0,i);
    return mn;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:33:9: error: 'i' was not declared in this scope
   33 |     for(i=0;i<n;i++)dfs(i,i,0,i);
      |         ^
dreaming.cpp:35:9: error: 'i' was not declared in this scope
   35 |     for(i=0;i<n;i++)if(!vis[i]){
      |         ^
dreaming.cpp:41:9: error: declaration of 'int x' shadows a parameter
   41 |     int x=st.top();
      |         ^
dreaming.cpp:43:9: error: declaration of 'int y' shadows a parameter
   43 |     int y=st.top();
      |         ^
dreaming.cpp:45:21: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&)'
   45 |     g[x].push_back(y);
      |                     ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from dreaming.cpp:3:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from 'int' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
dreaming.cpp:46:21: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(int&)'
   46 |     g[y].push_back(x);
      |                     ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from dreaming.cpp:3:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from 'int' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from 'int' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
dreaming.cpp:48:9: error: 'i' was not declared in this scope
   48 |     for(i=0;i<n;i++)dfs(i,i,0,i);
      |         ^