제출 #1024332

#제출 시각아이디문제언어결과실행 시간메모리
1024332Ahmed_Solyman기지국 (IOI20_stations)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "stations.h" typedef long long ll; vector<vector<int>>adj; int mark=0; vector<int>in; vector<int> label(int n, int k, vector<int> u, vector<int> v){ mark=0; adj.resize(n); in.resize(n); for(int i=0;i<n-1;i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } int mark=0; auto dfs=[&](auto &self,int i,int par){ in[i]=mark++; for(auto x:adj[i]){ if(x!=par)dfs(dfs,x,node); } return void(); }; for(int i=0;i<n;i++){ if(adj[i].size()==1){ dfs(i,i);break; } } return in; } int find_next_station(int s, int t,vector<int> c){ int p=0; for(auto i:c){ if(i<=s){ p=i;continue; } if(i<=t){ return i; } } return p; }

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp: In lambda function:
stations.cpp:21:23: error: use of 'dfs' before deduction of 'auto'
   21 |             if(x!=par)dfs(dfs,x,node);
      |                       ^~~
stations.cpp:21:27: error: use of 'dfs' before deduction of 'auto'
   21 |             if(x!=par)dfs(dfs,x,node);
      |                           ^~~
stations.cpp:21:33: error: 'node' was not declared in this scope
   21 |             if(x!=par)dfs(dfs,x,node);
      |                                 ^~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:27:20: error: no match for call to '(label(int, int, std::vector<int>, std::vector<int>)::<lambda(auto:1&, int, int)>) (int&, int&)'
   27 |             dfs(i,i);break;
      |                    ^
stations.cpp:18:14: note: candidate: 'template<class auto:1> label(int, int, std::vector<int>, std::vector<int>)::<lambda(auto:1&, int, int)>'
   18 |     auto dfs=[&](auto &self,int i,int par){
      |              ^
stations.cpp:18:14: note:   template argument deduction/substitution failed:
stations.cpp:27:20: note:   candidate expects 3 arguments, 2 provided
   27 |             dfs(i,i);break;
      |                    ^