제출 #612495

#제출 시각아이디문제언어결과실행 시간메모리
612495MohamedAliSaidane장난감 기차 (IOI17_train)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include "train.h" using namespace std; typedef long long ll; typedef double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pii> vpi; typedef vector<pll> vpl; #define pb push_back #define popb pop_back #define all(x) (x).begin(),(x).end() #define ff first #define ss second const int nax = 5004; const int MOD = 1e9 + 7; //std::vector<int> who_wins(std::vector<int> a, std::vector<int> r, std::vector<int> u, std::vector<int> v); int n, m; vi adj[nax]; int vis[nax]; int A[nax], C[nax], self[nax]; int dfs(int x, int dep = n) { vis[x] = 1; dep = C[x] ? n: dep; if(dep == 0) return A[x] ? 0 : 1; int rep = 0; for(auto e: adj[x]) { if(vis[e]) { if(A[x]) rep = 1; } else { if(A[e] == A[x]) { if(rep == 0 ) rep = dfs(e, dep - 1); } else { if(rep == 0) rep = 1 - dfs(e, dep - 1); } } } vis[x] = 0; return rep; } vi who_wins(vi a, vi r, vi u, vi v) { n = a.size(); m = u.size(); for(int i = 0 ; i < n; i++) { A[i] = a[i]; C[i ] = r[i]; } for(int i = 0 ; i < m; i ++) { adj[u[i]].pb(v[i]); if(u[i] == v[i]) self[i] = 1; } vi ans(n); for(int i = n - 1;i >= 0; i--) { if(a[i]) { if(C[i] && self[i]) ans[i] = 1; else { for(auto e: adj[i]) ans = ans[i] | ans[e]; } } else { if(!C[i] && self[i]) ans[i] = 0; else { ans[i] = 1; for(auto e: adj[i]) ans[i] &= ans[e]; } } } return ans; } /* int main() { int n, m; assert(2 == scanf("%d %d", &n, &m)); vector<int> a(n), r(n), u(m), v(m); for(int i = 0; i < n; i++) assert(1 == scanf("%d", &a[i])); for(int i = 0; i < n; i++) assert(1 == scanf("%d", &r[i])); for(int i = 0; i < m; i++) assert(2 == scanf("%d %d", &u[i], &v[i])); vector<int> res = who_wins(a, r, u, v); for(int i = 0; i < (int)res.size(); i++) printf(i ? " %d" : "%d", res[i]); printf("\n"); return 0; } */

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

train.cpp: In function 'vi who_wins(vi, vi, vi, vi)':
train.cpp:88:45: error: no match for 'operator=' (operand types are 'vi' {aka 'std::vector<int>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   88 |                         ans = ans[i] | ans[e];
      |                                             ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from train.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from train.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~