제출 #146500

#제출 시각아이디문제언어결과실행 시간메모리
146500nekiToy Train (IOI17_train)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "train.h" #define loop(i, a, b) for(int i=a;i<b;i++) #define maxn 20100 using namespace std; vector<int> ba[maxn], fo[maxn], ans, req, *po; void dfs(int u){loop(i, 0, ba[u].size()){ ba[u][i]--; if(ba[u][i]==0 && !po[i]) dfs(ba[u][i]);}}; vector<int> who_wins(vector<int> A, vector<int> C, vector<int> U, vector<int> V){ int n=A.size(), m=U.size();po=C; loop(i, 0, m) ba[V[i]].push_back(U[i]), fo[U[i]].push_back(V[i]); ans.resize(n, 1), req.resize(n); bool cn=1; while(cn){ cn=0; loop(i, 0, n) req[i]=(A[i])? 1:fo[i].size(); loop(i, 0, n) if(po[i]&&ans[i]) dfs(i); loop(i, 0, n) if(ans[i]!=(req[i]<1)) ans[i]=(req[i]<1), cn=1; } return ans; }

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

train.cpp: In function 'void dfs(int)':
train.cpp:3:36: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define loop(i, a, b) for(int i=a;i<b;i++)
train.cpp:8:22:
 void dfs(int u){loop(i, 0, ba[u].size()){ ba[u][i]--; if(ba[u][i]==0 && !po[i]) dfs(ba[u][i]);}};
                      ~~~~~~~~~~~~~~~~~~
train.cpp:8:17: note: in expansion of macro 'loop'
 void dfs(int u){loop(i, 0, ba[u].size()){ ba[u][i]--; if(ba[u][i]==0 && !po[i]) dfs(ba[u][i]);}};
                 ^~~~
train.cpp:8:73: error: no match for 'operator!' (operand type is 'std::vector<int>')
 void dfs(int u){loop(i, 0, ba[u].size()){ ba[u][i]--; if(ba[u][i]==0 && !po[i]) dfs(ba[u][i]);}};
                                                                         ^~~~~~
train.cpp:8:73: note: candidate: operator!(bool) <built-in>
train.cpp:8:73: note:   no known conversion for argument 1 from 'std::vector<int>' to 'bool'
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:11:33: error: cannot convert 'std::vector<int>' to 'std::vector<int>*' in assignment
   int n=A.size(), m=U.size();po=C;
                                 ^
train.cpp:19:27: error: no match for 'operator&&' (operand types are 'std::vector<int>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}')
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
train.cpp:19:27: note: candidate: operator&&(bool, bool) <built-in>
train.cpp:19:27: note:   no known conversion for argument 1 from 'std::vector<int>' to 'bool'
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from train.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:412:5: note: candidate: template<class _Dom1, class _Dom2> std::_Expr<std::_BinClos<std::__logical_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)
     _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
     ^
/usr/include/c++/7/bits/valarray_after.h:412:5: note:   template argument deduction/substitution failed:
train.cpp:19:34: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
                                  ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from train.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:412:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__logical_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)
     _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
     ^
/usr/include/c++/7/bits/valarray_after.h:412:5: note:   template argument deduction/substitution failed:
train.cpp:19:34: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
                                  ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from train.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:412:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__logical_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)
     _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
     ^
/usr/include/c++/7/bits/valarray_after.h:412:5: note:   template argument deduction/substitution failed:
train.cpp:19:34: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
                                  ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from train.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:412:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__logical_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)
     _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
     ^
/usr/include/c++/7/bits/valarray_after.h:412:5: note:   template argument deduction/substitution failed:
train.cpp:19:34: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
                                  ^
In file included from /usr/include/c++/7/valarray:592:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95,
                 from train.cpp:1:
/usr/include/c++/7/bits/valarray_after.h:412:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__logical_and, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)
     _DEFINE_EXPR_BINARY_OPERATOR(&&, __logical_and)
     ^
/usr/include/c++/7/bits/valarray_after.h:412:5: note:   template argument deduction/substitution failed:
train.cpp:19:34: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
                                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from train.cpp:1:
/usr/include/c++/7/valarray:1182:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__logical_and, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const std::valarray<_Tp>&, const std::valarray<_Tp>&)
 _DEFINE_BINARY_OPERATOR(&&, __logical_and)
 ^
/usr/include/c++/7/valarray:1182:1: note:   template argument deduction/substitution failed:
train.cpp:19:34: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
                                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from train.cpp:1:
/usr/include/c++/7/valarray:1182:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__logical_and, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const std::valarray<_Tp>&, const _Tp&)
 _DEFINE_BINARY_OPERATOR(&&, __logical_and)
 ^
/usr/include/c++/7/valarray:1182:1: note:   template argument deduction/substitution failed:
train.cpp:19:34: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
                                  ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from train.cpp:1:
/usr/include/c++/7/valarray:1182:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__logical_and, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const _Tp&, const std::valarray<_Tp>&)
 _DEFINE_BINARY_OPERATOR(&&, __logical_and)
 ^
/usr/include/c++/7/valarray:1182:1: note:   template argument deduction/substitution failed:
train.cpp:19:34: note:   mismatched types 'const std::valarray<_Tp>' and '__gnu_cxx::__alloc_traits<std::allocator<int> >::value_type {aka int}'
     loop(i, 0, n) if(po[i]&&ans[i]) dfs(i);
                                  ^