Submission #430715

#TimeUsernameProblemLanguageResultExecution timeMemory
430715JUANDI321기지국 (IOI20_stations)C++17
Compilation error
0 ms0 KiB
#include "stations.h" #include <vector> #include <iostream> using namespace std; vector<vector<int>> g(1000+10); vector<int> l(1000 +10); bool ch[1010]; void dfs(int node, int& i) { if(ch[node])return; ch[node]=true; l[i] = node; //cout<<node<<endl; for(auto y : g[node]) { if(!ch[y]) { dfs(y, i+1); } } } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> labels(n); for(int i = 0; i < n-1; i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } int spn = 0; for(int i = 0; i < n; i++) { if(g[i].size() == 1) { spn = i; break; } } int pos = 0; dfs(spn, pos);//cout<<"hola"<<endl; for (int i = 0; i < n; i++) { labels[l[i]] = i; //cout<<"l[i] "<<l[i]<<" i "<<i<<endl; } return labels; } int find_next_station(int s, int t, vector<int> c) { if(t>s)return s+1; return s-1; }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int&)':
stations.cpp:20:15: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int'
   20 |       dfs(y, i+1);
      |              ~^~
stations.cpp:10:25: note:   initializing argument 2 of 'void dfs(int, int&)'
   10 | void dfs(int node, int& i)
      |                    ~~~~~^