Submission #243183

#TimeUsernameProblemLanguageResultExecution timeMemory
243183crossing0verToy Train (IOI17_train)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define vi vector<int> #define pb push_back //#include "train.h" using namespace std; int n,m; vi X,Y,good,who,adj[5009]; vi CASE1() { vi ans(n); for (int i = n-1; i >= 0; i--) { bool flag = 0; for (int j : adj[i]) { if (j == i && who[i] == good[i]) { ans[i] = who[i]; flag = 1; break; } if (who[i] == ans[j] && j != i) { flag = 1; ans[i] = ans[j]; break; } } if (flag == 0) ans[i] = (!who[i]); } return ans; } vector<int> vis(5005),P(5005),G(5005),depth(5005); bool dfs(int v,int tp) { vis[v] = 1; bool ans = 0 if (tp && good[v] == 2) ans = 1; for (int i : adj[v]) { if (vis[i] && good[i]) good[i] = 2; else ans|=dfs(v,tp); } return ans; } vi CASE2() { vi ans(n);//,vis(n),P(n),G(n),depth(n); for (int i = 0; i < n; i++) { if (good[i]) dfs(i,0); fill(vis,0,sizeof vis); } for (int i = 0; i < n; i++) { ans[i] = dfs(i,1); } return ans; } vi who_wins(vi a1, vi r, vi st, vi en) { n = a1.size(), m = st.size(); X = st; Y = en; for (int i = 0; i < m; i++) adj[X[i]].pb(Y[i]); good = r; who = a1; bool case1 = 1,case2 = 1; for (int i = 0; i < m; i++) { if (X[i] != Y[i] && X[i]+1 != Y[i]) case1 = 0; } for (int i = 0;i < n; i++) if (who[i] == 0) case2 = 0; if (case2) return CASE2(); if (case1) return CASE1(); // return res; return vector<int>(); } /* main() { cin >> n >> m; vi r(n),a1(n),st(m),en(m); for (int i = 0; i < n; i++) cin >> a1[i]; for (int i = 0; i < n ;i++) cin >> r[i]; for (int i = 0; i < m ;i++) { int x,y; cin >> st[i] >> en[i]; } vi ans = who_wins(a1,r,st,en); for (int i :ans) cout << i <<' '; }*/

Compilation message (stderr)

train.cpp: In function 'bool dfs(int, int)':
train.cpp:33:2: error: expected ',' or ';' before 'if'
  if (tp && good[v] == 2) ans = 1;
  ^~
train.cpp: In function 'std::vector<int> CASE2()':
train.cpp:44:24: error: no matching function for call to 'fill(std::vector<int>&, int, long unsigned int)'
   fill(vis,0,sizeof vis);
                        ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from train.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:724:5: note: candidate: template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)
     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
     ^~~~
/usr/include/c++/7/bits/stl_algobase.h:724:5: note:   template argument deduction/substitution failed:
train.cpp:44:24: note:   deduced conflicting types for parameter '_ForwardIterator' ('std::vector<int>' and 'int')
   fill(vis,0,sizeof vis);
                        ^
In file included from /usr/include/c++/7/deque:66:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:68,
                 from train.cpp:1:
/usr/include/c++/7/bits/deque.tcc:965:5: note: candidate: template<class _Tp> void std::fill(const std::_Deque_iterator<_Tp, _Tp&, _Tp*>&, const std::_Deque_iterator<_Tp, _Tp&, _Tp*>&, const _Tp&)
     fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
     ^~~~
/usr/include/c++/7/bits/deque.tcc:965:5: note:   template argument deduction/substitution failed:
train.cpp:44:24: note:   'std::vector<int>' is not derived from 'const std::_Deque_iterator<_Tp, _Tp&, _Tp*>'
   fill(vis,0,sizeof vis);
                        ^
In file included from /usr/include/c++/7/vector:65:0,
                 from /usr/include/c++/7/functional:61,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:71,
                 from train.cpp:1:
/usr/include/c++/7/bits/stl_bvector.h:398:3: note: candidate: void std::fill(std::_Bit_iterator, std::_Bit_iterator, const bool&)
   fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x)
   ^~~~
/usr/include/c++/7/bits/stl_bvector.h:398:3: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::_Bit_iterator'