Submission #146487

#TimeUsernameProblemLanguageResultExecution timeMemory
146487nekiToy Train (IOI17_train)C++14
Compilation error
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; vector<int> who_wins(vector<int> A, vector<int> C, vector<int> U, vector<int> V){ int n=A.size(), m=U.size() 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); auto dfs=[&](int u){loop(i, 0, ba[u].size()) ba[u][i]--, if(ba[u][i]==0) dfs(ba[u][i]);} bool cn=1; while(cn){ cn=0; loop(i, 0, n) req[i]=(A[i])? 1:fo[i].size(); loop(i, 0, n) if(c[i]&&ans[i]) dfs(i); loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1; } return ans; }

Compilation message (stderr)

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:3:23: error: expected ',' or ';' before 'for'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                       ^
train.cpp:11:3: note: in expansion of macro 'loop'
   loop(i, 0, m) ba[V[i]].push_back(U[i]), fo[U[i]].push_back(V[i]);
   ^~~~
train.cpp:11:8: error: 'i' was not declared in this scope
   loop(i, 0, m) ba[V[i]].push_back(U[i]), fo[U[i]].push_back(V[i]);
        ^
train.cpp:3:35: note: in definition of macro 'loop'
 #define loop(i, a, b) for(int i=a;i<b;i++)
                                   ^
train.cpp: In lambda function:
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:13:28:
   auto dfs=[&](int u){loop(i, 0, ba[u].size()) ba[u][i]--, if(ba[u][i]==0) dfs(ba[u][i]);}
                            ~~~~~~~~~~~~~~~~~~
train.cpp:13:23: note: in expansion of macro 'loop'
   auto dfs=[&](int u){loop(i, 0, ba[u].size()) ba[u][i]--, if(ba[u][i]==0) dfs(ba[u][i]);}
                       ^~~~
train.cpp:13:60: error: expected primary-expression before 'if'
   auto dfs=[&](int u){loop(i, 0, ba[u].size()) ba[u][i]--, if(ba[u][i]==0) dfs(ba[u][i]);}
                                                            ^~
train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:14:3: error: expected ',' or ';' before 'bool'
   bool cn=1;
   ^~~~
train.cpp:15:9: error: 'cn' was not declared in this scope
   while(cn){
         ^~
train.cpp:15:9: note: suggested alternative: 'n'
   while(cn){
         ^~
         n
train.cpp:18:22: error: 'c' was not declared in this scope
     loop(i, 0, n) if(c[i]&&ans[i]) dfs(i);
                      ^
train.cpp:19:31: error: no match for 'operator<' (operand types are 'std::vector<int>' and 'int')
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                            ~~~^~
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from train.cpp:1:
/usr/include/c++/7/bits/regex.h:962:5: note: candidate: template<class _BiIter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const std::__cxx11::sub_match<_BiIter>&)
     operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:962:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from train.cpp:1:
/usr/include/c++/7/bits/regex.h:1041:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const std::__cxx11::sub_match<_BiIter>&)
     operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1041:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from train.cpp:1:
/usr/include/c++/7/bits/regex.h:1121:5: note: candidate: template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)
     operator<(const sub_match<_Bi_iter>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1121:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from train.cpp:1:
/usr/include/c++/7/bits/regex.h:1198:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const std::__cxx11::sub_match<_BiIter>&)
     operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1198:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from train.cpp:1:
/usr/include/c++/7/bits/regex.h:1272:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)
     operator<(const sub_match<_Bi_iter>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1272:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from train.cpp:1:
/usr/include/c++/7/bits/regex.h:1349:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const std::__cxx11::sub_match<_BiIter>&)
     operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1349:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/regex:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:110,
                 from train.cpp:1:
/usr/include/c++/7/bits/regex.h:1429:5: note: candidate: template<class _Bi_iter> bool std::__cxx11::operator<(const std::__cxx11::sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)
     operator<(const sub_match<_Bi_iter>& __lhs,
     ^~~~~~~~
/usr/include/c++/7/bits/regex.h:1429:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/future:39:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:105,
                 from train.cpp:1:
/usr/include/c++/7/thread:281:3: note: candidate: bool std::operator<(std::thread::id, std::thread::id)
   operator<(thread::id __x, thread::id __y) noexcept
   ^~~~~~~~
/usr/include/c++/7/thread:281:3: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::thread::id'
In file included from /usr/include/c++/7/forward_list:38:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:104,
                 from train.cpp:1:
/usr/include/c++/7/bits/forward_list.h:1391:5: note: candidate: template<class _Tp, class _Alloc> bool std::operator<(const std::forward_list<_Tp, _Alloc>&, const std::forward_list<_Tp, _Alloc>&)
     operator<(const forward_list<_Tp, _Alloc>& __lx,
     ^~~~~~~~
/usr/include/c++/7/bits/forward_list.h:1391:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::forward_list<_Tp, _Alloc>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
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:1186:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__less, _Tp>::result_type> std::operator<(const _Tp&, const std::valarray<_Tp>&)
 _DEFINE_BINARY_OPERATOR(<, __less)
 ^
/usr/include/c++/7/valarray:1186:1: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   mismatched types 'const std::valarray<_Tp>' and 'int'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
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:1186:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__less, _Tp>::result_type> std::operator<(const std::valarray<_Tp>&, const _Tp&)
 _DEFINE_BINARY_OPERATOR(<, __less)
 ^
/usr/include/c++/7/valarray:1186:1: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
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:1186:1: note: candidate: template<class _Tp> std::_Expr<std::_BinClos<std::__less, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__less, _Tp>::result_type> std::operator<(const std::valarray<_Tp>&, const std::valarray<_Tp>&)
 _DEFINE_BINARY_OPERATOR(<, __less)
 ^
/usr/include/c++/7/valarray:1186:1: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::valarray<_Tp>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
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:416:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__less, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__less, 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(<, __less)
     ^
/usr/include/c++/7/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
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:416:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__less, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__less, 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(<, __less)
     ^
/usr/include/c++/7/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
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:416:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__less, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__less, 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(<, __less)
     ^
/usr/include/c++/7/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
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:416:5: note: candidate: template<class _Dom> std::_Expr<std::_BinClos<std::__less, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__less, 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(<, __less)
     ^
/usr/include/c++/7/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
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:416:5: note: candidate: template<class _Dom1, class _Dom2> std::_Expr<std::_BinClos<std::__less, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__less, 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(<, __less)
     ^
/usr/include/c++/7/bits/valarray_after.h:416:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/stack:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:89,
                 from train.cpp:1:
/usr/include/c++/7/bits/stl_stack.h:311:5: note: candidate: template<class _Tp, class _Seq> bool std::operator<(const std::stack<_Tp, _Seq>&, const std::stack<_Tp, _Seq>&)
     operator<(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
     ^~~~~~~~
/usr/include/c++/7/bits/stl_stack.h:311:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::stack<_Tp, _Seq>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/set:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from train.cpp:1:
/usr/include/c++/7/bits/stl_multiset.h:913:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator<(const std::multiset<_Key, _Compare, _Alloc>&, const std::multiset<_Key, _Compare, _Alloc>&)
     operator<(const multiset<_Key, _Compare, _Alloc>& __x,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_multiset.h:913:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::multiset<_Key, _Compare, _Alloc>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/set:61:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:87,
                 from train.cpp:1:
/usr/include/c++/7/bits/stl_set.h:930:5: note: candidate: template<class _Key, class _Compare, class _Alloc> bool std::operator<(const std::set<_Key, _Compare, _Alloc>&, const std::set<_Key, _Compare, _Alloc>&)
     operator<(const set<_Key, _Compare, _Alloc>& __x,
     ^~~~~~~~
/usr/include/c++/7/bits/stl_set.h:930:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::set<_Key, _Compare, _Alloc>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from train.cpp:1:
/usr/include/c++/7/bits/stl_queue.h:336:5: note: candidate: template<class _Tp, class _Seq> bool std::operator<(const std::queue<_Tp, _Seq>&, const std::queue<_Tp, _Seq>&)
     operator<(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
     ^~~~~~~~
/usr/include/c++/7/bits/stl_queue.h:336:5: note:   template argument deduction/substitution failed:
train.cpp:19:32: note:   'std::vector<int>' is not derived from 'const std::queue<_Tp, _Seq>'
     loop(i, 0, n) if(ans!=(req<1)) ans=(req<1), cn=1;
                                ^
In file included from /usr/include/c++/7/vector:64:0,
                 from /usr/include/c++/7/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:86,
                 from train.cpp:1:
/usr/include/c++/7/bits/stl_vector.h:1613:5: note: candidate: templ