제출 #1228396

#제출 시각아이디문제언어결과실행 시간메모리
1228396TrumlingSaveit (IOI10_saveit)C++20
컴파일 에러
0 ms0 KiB
#include "grader.h" #include "encoder.h" //Trumling © //Αφόδευε υψηλά και ηγνάντει #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define F first #define S second #define enter cout<<'\n'; #define INF 99999999999999999 #define MOD 998244353 #define all(x) x.begin(),x.end() vector<vector<ll>>g; vector<vector<ll>>dist; vector<vector<ll>>tree; vector<ll>par; ll n,h,m; void encode(int nv, int nh, int ne, int *v1, int *v2){ n=nv; h=nh; m=ne; ll count=0; g.assign(n,vector<ll>()); dist.assign(n,vector<ll>(n,INF)); tree.assign(n,vector<ll>()); par.assign(n,-1); for(int i=0;i<m;i++) { g[v1[i]].pb(v2[i]); g[v2[i]].pb(v1[i]); } for(int i=0;i<n;i++) { vector<bool>vis(n,0); vis[i]=1; queue<ll>q; q.push(i); dist[i][i]=0; while(!q.empty()) { ll curr=q.front(); q.pop(); for(auto x:g[curr]) if(!vis[x]) { if(i==0) { par[x]=curr; tree[curr]=x; } q.push(x); dist[i][x]=dist[i][curr]+1; vis[x]=1; } } } for(int i=1;i<n;i++) { ll temp=par[i]; for(int j=0;j<10;j++) { encode_bit(temp%2); temp/=2; } } for(int i=0;i<n;i++) sort(all(tree[i])); queue<ll>q; for(int i=1;i<h;i++) { q.push(0); while(!q.empty()) { ll curr=q.front(); q.pop(); for(auto x:tree[curr]) { count+=2; if(dist[i][curr] < dist[i][x]) { encode_bit(1); encode_bit(1); } if(dist[i][curr] == dist[i][x]) { encode_bit(0); } if(dist[i][curr] > dist[i][x]) { encode_bit(1); encode_bit(0); } q.push(x); } } } assert(count<81000); return; }
#include "grader.h" #include "decoder.h" //Trumling © //Αφόδευε υψηλά και ηγνάντει #include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back #define F first #define S second #define enter cout<<'\n'; #define INF 99999999999999999 #define MOD 998244353 #define all(x) x.begin(),x.end() vector<vector<ll>>tree; vector<ll>par; ll n,h; void decode(int nv, int nh) { n=nv; h=nh; tree.assign(n,vector<ll>()); par.assign(n,0); for(int i=1;i<n;i++) { for(int j=0;j<10;j++) if(decode_bit()) par[i]+=(1<<j); tree[par[i]].pb(i); } for(int i=0;i<n;i++) sort(all(tree[i])); queue<ll>q; vector<vector<ll>>p(n,vector<ll>(n,0)); for(int i=1;i<h;i++) { vector<ll>dist(n,0); q.push(0); while(!q.empty()) { ll curr=q.front(); q.pop(); for(auto x:tree[curr]) { bool bit=decode_bit(); if(!bit) { p[curr][x]=0; p[x][curr]=0; } else { ll id=2*x + decode_bit(); if(id==2) { p[curr][x]=-1; p[x][curr]=1; } if(id==3) { p[curr][x]=1; p[x][curr]=-1; } } q.push(x); } } ll now=i; while(now!=0) { dist[par[now]]=dist[now]+p[now][par[now]]; now=par[now]; } q.push(0); while(!q.empty()) { ll curr=q.front(); q.pop(); for(auto x:tree[curr]) { dist[x] = dist[curr] + p[curr][x]; q.push(x); } } for(int j=0;j<n;j++) hops(i,j,dist[j]); } queue<pair<ll,ll>>q2; q2.push({0,0}); hops(0,0,0); while(!q2.empty()) { pair<ll,ll>curr=q2.front(); q2.pop(); for(auto x:tree[curr.F]) { q2.push({x,curr.S+1}); hops(0,x,curr.S+1); } } }

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

# 1번째 컴파일 단계

encoder.cpp: In function 'void encode(int, int, int, int*, int*)':
encoder.cpp:55:28: error: no match for 'operator=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'} and 'long long int')
   55 |                 tree[curr]=x;
      |                            ^
In file included from /usr/include/c++/11/vector:72,
                 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 encoder.cpp:5:
/usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'long long int' to 'const std::vector<long long int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 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 encoder.cpp:5:
/usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<long long int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~