Submission #1174802

#TimeUsernameProblemLanguageResultExecution timeMemory
1174802khanhphucscratchStations (IOI20_stations)C++20
Compilation error
0 ms0 KiB
#include "stations.h" #include<bits/stdc++.h> using namespace std; //Subtask 1 vector<int> ad[1005], order; int deg[1005]; bool visited[1005]; void dfs(int u, int par) { order.push_back(u); visited[u] = 1; for(int v : ad[u]) if(visited[v] == 0) dfs(v, u); } vector<int> label(int n, int k, vector<int> a, vector<int> b) { for(int i = 0; i < n; i++){ deg[i] = 0; order[i].clear(); ad[i].clear(); visited[i] = 0; } for(int i = 0; i < n-1; i++){ deg[a[i]]++; deg[b[i]]++; ad[a[i]].push_back(b[i]); ad[b[i]].push_back(a[i]); } int root = 0; while(deg[root] == 2){ root++; } dfs(root, -1); vector<int> ans(n); for(int i = 0; i < n; i++) ans[order[i]] = i; return ans; } int find_next_station(int s, int t, vector<int> c) { if(c.size() == 1) return c[0]; if(s < t){ if(c[0] > c[1]) return c[0]; else return c[1]; } else{ if(c[0] > c[1]) return c[1]; else return c[0]; } } /*int main() { int type; cin>>type; if(type == 1){ vector<int> a, b; int n; cin>>n; for(int i = 0; i < n-1; i++){ int u, v; cin>>u>>v; a.push_back(u); b.push_back(v); } vector<int> ans = label(n, 0, a, b); for(int i : ans) cout<<i<<" "; } else{ int s, t, n; cin>>s>>t>>n; vector<int> adj(n); for(int i = 0; i < n; i++) cin>>adj[i]; cout<<find_next_station(s, t, adj); } } */

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:16:30: error: request for member 'clear' in 'order.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
   16 |         deg[i] = 0; order[i].clear(); ad[i].clear(); visited[i] = 0;
      |                              ^~~~~