제출 #1312044

#제출 시각아이디문제언어결과실행 시간메모리
1312044shebDrivers (BOI24_drivers)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const string yes = "TAIP"; const string no = "NE"; int32_t main() { int n, e, q;cin>>n>>e>>q; vector<pair<int, int>> M[n+1]; for (int i = 0; i < e; i++) { int a, b, t;cin>>a>>b>>t; M[a].push_back(make_pair(b, t)); M[b].push_back(make_pair(a, t)); } vector<string> ANS; for (int i = 0; i < q; i++) { int a, b, k;cin>>a>>b>>k; set<int> V; bool done = false function<void(int, int, int)> search = [&V, &M, &search](int a, int b, int k) { if (a == b) {done = true; return;} V.insert(a); for (auto it = M[a].begin(); it != M[a].end(); it++) { if ( it->second > k or V.find(it->first) != V.end() ) continue; search(it->first, b, k); } }; search(a, b, k); ANS.push_back((done)? yes: no); } for (string &s: ANS) cout << s << '\n'; return 0; }

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

Main.cpp: In function 'int32_t main()':
Main.cpp:22:9: error: expected ',' or ';' before 'function'
   22 |         function<void(int, int, int)> search = [&V, &M, &search](int a, int b, int k) {
      |         ^~~~~~~~
In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from Main.cpp:1:
/usr/include/c++/13/bits/stl_algo.h: In instantiation of 'constexpr _ForwardIterator std::search(_ForwardIterator, _ForwardIterator, const _Searcher&) [with _ForwardIterator = long long int; _Searcher = long long int]':
Main.cpp:33:15:   required from here
/usr/include/c++/13/bits/stl_algo.h:4275:24: error: expression cannot be used as a function
 4275 |     { return __searcher(__first, __last).first; }
      |              ~~~~~~~~~~^~~~~~~~~~~~~~~~~