제출 #877593

#제출 시각아이디문제언어결과실행 시간메모리
877593vjudge1Stranded Far From Home (BOI22_island)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define eb emplace_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define uniq(x) x.erase(unique(all(x)), x.end()) #define rall(x) x.rbegin(), x.rend() //#define int long long using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; const int mod = 1e9 + 7; const int LOG = 20; const int maxn = 1e5 + 5; const double eps = 1e-9; void setIO() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); } vector<vector<int> > graph; vector<ll> sub; vector<bool> ans; vector<int> val; void get_sub(int u, int p) { sub[u] = val[u]; for(int &v : graph[u]) { if(v == p) continue; dfs(v, u); sub[u] += sub[v]; } } void dfs(int u, int p) { if(sub[u] >= val[p]) ans[u] |= ans[p]; for(int &v : graph[u]) { if(v == p) continue; dfs(v, u); } } int32_t main() { setIO(); int n, m; cin >> n >> m; val.resize(n+1); for(int i=1; i<=n; i++) cin >> val[i]; graph.resize(n+1); for(int i=0; i<m; i++) { int a, b; cin >> a >> b; graph[a].push_back(b); graph[b].push_back(a); } if(n <= 2000 && m <= 2000) { auto dijkstra = [&](int a) { //cout << a << ": \n"; int cnt = 0; ll total = 0; vector<bool> vis(n+1); priority_queue<pll, vector<pll>, greater<pll> > pq; pq.push({ 0, a }); while(!pq.empty()) { int u = pq.top().second; pq.pop(); //cout << u << '\n'; if(vis[u] || (total < val[u] && u != a)) continue; vis[u] = true; total += val[u]; cnt++; for(int &v : graph[u]) { if(vis[v]) continue; pq.push({ val[v], v }); } } return (cnt == n); }; for(int i=1; i<=n; i++) cout << dijkstra(i); return 0; } sub.resize(n+1); ans.resize(n+1); get_sub(1, 0); ans[1] = 1; dfs(1, 1); for(int i=1; i<=n; i++) cout << ans[i]; return 0; }

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

island.cpp: In function 'void get_sub(int, int)':
island.cpp:40:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   40 |         dfs(v, u);
      |         ^~~
      |         ffs
island.cpp: In function 'void dfs(int, int)':
island.cpp:46:33: error: no match for 'operator|=' (operand types are 'std::vector<bool>::reference' and 'std::vector<bool>::reference')
   46 |     if(sub[u] >= val[p]) ans[u] |= ans[p];
      |                          ~~~~~~~^~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:45,
                 from island.cpp:1:
/usr/include/c++/10/cstddef:160:3: note: candidate: 'constexpr std::byte& std::operator|=(std::byte&, std::byte)'
  160 |   operator|=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/cstddef:160:20: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
  160 |   operator|=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from island.cpp:1:
/usr/include/c++/10/bits/ios_base.h:99:3: note: candidate: 'const std::_Ios_Fmtflags& std::operator|=(std::_Ios_Fmtflags&, std::_Ios_Fmtflags)'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:99:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
   99 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:141:3: note: candidate: 'const std::_Ios_Openmode& std::operator|=(std::_Ios_Openmode&, std::_Ios_Openmode)'
  141 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:141:29: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
  141 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/ios_base.h:181:3: note: candidate: 'const std::_Ios_Iostate& std::operator|=(std::_Ios_Iostate&, std::_Ios_Iostate)'
  181 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |   ^~~~~~~~
/usr/include/c++/10/bits/ios_base.h:181:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
  181 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
      |              ~~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:105,
                 from island.cpp:1:
/usr/include/c++/10/future:167:18: note: candidate: 'std::launch& std::operator|=(std::launch&, std::launch)'
  167 |   inline launch& operator|=(launch& __x, launch __y)
      |                  ^~~~~~~~
/usr/include/c++/10/future:167:37: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::launch&'
  167 |   inline launch& operator|=(launch& __x, launch __y)
      |                             ~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:127,
                 from island.cpp:1:
/usr/include/c++/10/charconv:680:3: note: candidate: 'constexpr std::chars_format& std::operator|=(std::chars_format&, std::chars_format)'
  680 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/10/charconv:680:28: note:   no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::chars_format&'
  680 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~