제출 #1228003

#제출 시각아이디문제언어결과실행 시간메모리
1228003Dzadzo사이버랜드 (APIO23_cyberland)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "cyberland.h" #define ll long long #define pb push_back #define S second #define F first #define pii pair<int,int> #define vi vector<int> #define vvi vector<vi> #define vvvi vector<vvi> #define vp vector<pii> #define vvp vector<vp> #define vb vector<bool> #define vvb vector<vb> #define INF 1000000000000000 #define MOD 1000000007 #define MAXN 200000 using namespace std; // #pragma GCC optimize("O3,unroll-loops") // #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") double solve(int n, int m, int K, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) { vvp adj(n); for (int i=0;i<m;i++) { adj[x[i]].pb({y[i],c[i]}); adj[y[i]].pb({x[i],c[i]}); } vector <vector <double>> dist(n,vector <double>(31,INF)); dist[h][0]=0; set <pair <pair <double,int>,int>> st; st.insert({{dist[h][0],0},h}); while (st.size()) { int v=st.begin()->S; int k=st.begin()->F.S; st.erase(st.begin()); for (auto &[to,w]:adj[v]) { if (dist[to][k] > dist[v][k]+w ) { st.erase({{dist[to][k],k},to}); dist[to][k]=dist[v][k]+w; st.insert({{dist[to][k],k},to}); } if (arr[to]==2 && k!=30) { if (dist[to][k+1] > 2*(dist[v][k]+w) ) { st.erase({{dist[to][k+1],k+1},to}); dist[to][k+1]=2*(dist[v][k]+w); st.insert({{dist[to][k+1],k+1},to}); } } } } vb visited(n); vb res=false; function<void(int)> dfs = [&](int v) { if (v==h) { res=true; return; } visited[v]=true; for (auto &[to,w]:adj[v]) { if (!visited[to]) { dfs(to); } } }; if (!res)return -1; dfs(0); double ans=INF; for (int i=0;i<n;i++) { if ((!arr[i] || !i) && visited[i]) { for (int q=0;q<=min(30,K);q++)ans=min(ans,dist[i][q] / (double)(1ll<<q)); } } return ans; } // int main() { // // cout<<solve(3,0,30,2,{},{},{},{}); // } /* 3 0 30 2 1 0 1 */

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

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:60:12: error: conversion from 'bool' to non-scalar type 'std::vector<bool>' requested
   60 |     vb res=false;
      |            ^~~~~
cyberland.cpp: In lambda function:
cyberland.cpp:63:17: error: no match for 'operator=' (operand types are 'std::vector<bool>' and 'bool')
   63 |             res=true;
      |                 ^~~~
In file included from /usr/include/c++/11/vector:68,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from cyberland.cpp:1:
/usr/include/c++/11/bits/stl_bvector.h:736:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(const std::vector<bool, _Alloc>&) [with _Alloc = std::allocator<bool>]'
  736 |       operator=(const vector& __x)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_bvector.h:736:31: note:   no known conversion for argument 1 from 'bool' to 'const std::vector<bool>&'
  736 |       operator=(const vector& __x)
      |                 ~~~~~~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_bvector.h:767:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::vector<bool, _Alloc>&&) [with _Alloc = std::allocator<bool>]'
  767 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_bvector.h:767:26: note:   no known conversion for argument 1 from 'bool' to 'std::vector<bool>&&'
  767 |       operator=(vector&& __x) noexcept(_Bit_alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_bvector.h:792:7: note: candidate: 'std::vector<bool, _Alloc>& std::vector<bool, _Alloc>::operator=(std::initializer_list<bool>) [with _Alloc = std::allocator<bool>]'
  792 |       operator=(initializer_list<bool> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_bvector.h:792:40: note:   no known conversion for argument 1 from 'bool' to 'std::initializer_list<bool>'
  792 |       operator=(initializer_list<bool> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~^~~
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:73:9: error: no match for 'operator!' (operand type is 'std::vector<bool>')
   73 |     if (!res)return -1;
      |         ^~~~
cyberland.cpp:73:9: note: candidate: 'operator!(bool)' (built-in)
cyberland.cpp:73:9: note:   no known conversion for argument 1 from 'std::vector<bool>' to 'bool'