Submission #972426

#TimeUsernameProblemLanguageResultExecution timeMemory
972426Nika533Dreaming (IOI13_dreaming)C++14
Compilation error
0 ms0 KiB
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #include "dreaming.h" #define pb push_back #define f first #define s second #define MOD 1000000007 #define flush fflush(stdout) #define all(x) (x).begin(),(x).end() #define allr(x) (x).rbegin(), (x).rend() #define pii pair<int,int> using namespace std; const int NMAX=1e5+5; int n,m,fix[NMAX],mx[NMAX],next[NMAX]; vector<pii> g[NMAX]; void dfs(int x, int p) { mx[x]=0; next[x]=-1; fix[x]=1; if (x!=p && g[x].size()==1) return; for (auto A:g[x]) { int y=A.f,w=A.s; if (y==p) continue; dfs(y,x); if (mx[x]<w+mx[y]) { mx[x]=w+mx[y]; next[x]=y; } } } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { n=N; m=M; for (int i=0; i<m; i++) { int a=A[i],b=B[i],c=T[i]; g[a].pb({b,c}); g[b].pb({a,c}); } //subtask 1 & 2 & 3 int ans=L; for (int i=0; i<n; i++) { if (fix[i]==0) { vector<int> v; dfs(i,i); int j=i; while (j>=0) { v.pb(j); j=next[j]; } int st=v.back(); v.clear(); dfs(st,st); j=st; while (j>=0) { v.pb(j); j=next[j]; } int d=mx[st],mn=1e9; for (auto x:v) { mn=min(mn,max(mx[x],d-mx[x])); } ans+=mn; } } return ans; }

Compilation message (stderr)

dreaming.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
dreaming.cpp: In function 'void dfs(int, int)':
dreaming.cpp:20:11: error: reference to 'next' is ambiguous
   20 |  mx[x]=0; next[x]=-1; fix[x]=1;
      |           ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
dreaming.cpp:16:28: note:                 'int next [100005]'
   16 | int n,m,fix[NMAX],mx[NMAX],next[NMAX];
      |                            ^~~~
dreaming.cpp:28:4: error: reference to 'next' is ambiguous
   28 |    next[x]=y;
      |    ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
dreaming.cpp:16:28: note:                 'int next [100005]'
   16 | int n,m,fix[NMAX],mx[NMAX],next[NMAX];
      |                            ^~~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:52:16: error: reference to 'next' is ambiguous
   52 |     v.pb(j); j=next[j];
      |                ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
dreaming.cpp:16:28: note:                 'int next [100005]'
   16 | int n,m,fix[NMAX],mx[NMAX],next[NMAX];
      |                            ^~~~
dreaming.cpp:60:16: error: reference to 'next' is ambiguous
   60 |     v.pb(j); j=next[j];
      |                ^~~~
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from dreaming.cpp:2:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: candidates are: 'template<class _InputIterator> _InputIterator std::next(_InputIterator, typename std::iterator_traits<_Iter>::difference_type)'
  213 |     next(_InputIterator __x, typename
      |     ^~~~
dreaming.cpp:16:28: note:                 'int next [100005]'
   16 | int n,m,fix[NMAX],mx[NMAX],next[NMAX];
      |                            ^~~~