Submission #488908

#TimeUsernameProblemLanguageResultExecution timeMemory
488908ssenseDreaming (IOI13_dreaming)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "dreaming.h" #define startt ios_base::sync_with_stdio(false);cin.tie(0); typedef long long ll; using namespace std; #define vint vector<int> #define all(v) v.begin(), v.end() #define MOD 1000000007 #define MOD2 998244353 #define MX 1000000000 #define MXL 1000000000000000000 #define PI (ld)2*acos(0.0) #define nax 200005 #define pb push_back #define sc second #define fr first //#define int unsigned long long //#define endl '\n' #define ld long double #define NO cout << "NO" << endl #define YES cout << "YES" << endl vector<vector<pair<int, int>> adj; int bfs(int s) { queue<pair<pair<int, int>, int>> q; q.push({{s, -1}, 0}); int now = 0; while(!q.empty()) { int node = q.front().fr.fr; int dist = q.front().sc; int parent = q.front().fr.sc; now = max(now, dist); q.pop(); for(auto v : adj[node]) { if(v.fr != parent) { q.push({{v.fr, node}, dist+v.sc}); } } } return now; } bool vis[105]; int dfs(int u, int par) { int ans = bfs(u); vis[u] = true; for(auto v : adj[u]) { if(v.fr != par) { ans = min(ans, dfs(v.fr, u)); } } return ans; } int travelTime(int n, int m, int l, int a[], int b[], int t[]) { adj.clear(); for(int i = 0; i < n; i++) { vector<pair<int, int>> cop; adj.pb(cop); vis[i] = false; } for(int i = 0; i < m; i++) { adj[a[i]].pb({b[i], t[i]}); adj[b[i]].pb({a[i], t[i]}); } int ans = 0; vint mx; for(int i = 0; i < n; i++) { if(!vis[i]) { mx.pb(dfs(i, -1)); } } assert(mx.size() == 2); sort(all(mx)); ans+=mx[mx.size()-1]; ans+=mx[mx.size()-2]; ans+=l; return ans; } /* int main() { int n, m, l; cin >> n >> m >> l; int a[m], b[m], t[m]; for(int i = 0; i < m; i++) { cin >> a[i] >> b[i] >> t[i]; } cout << travelTime(n, m, l, a, b, t) << endl; } */ /* 7 5 2 0 1 10 0 5 5 5 4 6 3 2 2 2 6 1 8 6 3 0 1 1 1 2 1 1 3 1 1 4 10 4 5 10 6 7 7 2 0 2 3 1 10 1 2 1 */

Compilation message (stderr)

dreaming.cpp:24:31: error: template argument 1 is invalid
   24 | vector<vector<pair<int, int>> adj;
      |                               ^~~
dreaming.cpp:24:31: error: template argument 2 is invalid
dreaming.cpp: In function 'int bfs(int)':
dreaming.cpp:38:16: error: 'adj' was not declared in this scope
   38 |   for(auto v : adj[node])
      |                ^~~
dreaming.cpp:42:37: error: no matching function for call to 'std::queue<std::pair<std::pair<int, int>, int> >::push(<brace-enclosed initializer list>)'
   42 |     q.push({{v.fr, node}, dist+v.sc});
      |                                     ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from dreaming.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:265:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<std::pair<int, int>, int>; _Sequence = std::deque<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<std::pair<int, int>, int>]'
  265 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:265:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<std::pair<int, int>, int>&'}
  265 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:270:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<std::pair<int, int>, int>; _Sequence = std::deque<std::pair<std::pair<int, int>, int>, std::allocator<std::pair<std::pair<int, int>, int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<std::pair<int, int>, int>]'
  270 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:270:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<std::pair<int, int>, int> >::value_type&&' {aka 'std::pair<std::pair<int, int>, int>&&'}
  270 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
dreaming.cpp: In function 'int dfs(int, int)':
dreaming.cpp:55:15: error: 'adj' was not declared in this scope
   55 |  for(auto v : adj[u])
      |               ^~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:67:2: error: 'adj' was not declared in this scope
   67 |  adj.clear();
      |  ^~~