제출 #1220033

#제출 시각아이디문제언어결과실행 시간메모리
1220033brinton던전 (IOI21_dungeons)C++20
컴파일 에러
0 ms0 KiB
#include "dungeons.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> s,p,w,l;
int N;
vector<vector<pair<long long,int>>> lj;//lj[k][start] after 2^k play, {earn_hero,nxt};
vector<int> toN;// how many step to N if all wins;
void init(int i_n, vector<int> i_s, vector<int> i_p, vector<int> i_w, vector<int> i_l) {
	N = i_n;
	s = i_s, p = i_p, w = i_w, l = i_l;
	lj = vector<vector<pair<int,int>>>(25,vector<pair<int,int>>(N));// atmost lost 2^24 times;
	for(int i = 0;i < N;i++){
		lj[0][i].first = p[i];
		lj[0][i].second = l[i];
	}
	for(int k = 1;k < 25;k++){
		for(int i = 0;i < N;i++){
			auto [earn_hero,nxt] = lj[k-1][i];
			auto [earn_hero2,nxt2] = lj[k-1][nxt];
			lj[k][i] = {earn_hero+earn_hero2,nxt2};
		}
	}
	toN = vector<int>(N+1,0);
	for(int i = N-1;i >= 0;i--){
		toN[i] = toN[w[i]]+1;
	}
}

long long simulate(int x, int z) {
	long long hero = z;
	int cur = x;
	for(int k = 24;k >= 0;k--){
		auto [earn_hero,nxt] = lj[k][cur];
		if(hero + earn_hero < s[0]) {
			hero += earn_hero;
			cur = nxt;
		}
	}
	if(hero < s[0]){
		auto [earn_hero,nxt] = lj[0][cur];
		hero += earn_hero, cur = nxt;
	}
	hero += toN[cur]*s[0];
	return hero;
	return 0;
}

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

dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
dungeons.cpp:12:71: error: no match for 'operator=' (operand types are 'std::vector<std::vector<std::pair<long long int, int> > >' and 'std::vector<std::vector<std::pair<int, int> > >')
   12 |         lj = vector<vector<pair<int,int>>>(25,vector<pair<int,int>>(N));// atmost lost 2^24 times;
      |                                                                       ^
In file included from /usr/include/c++/11/vector:72,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/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 = std::vector<std::pair<long long int, int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, int> > >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::vector<std::vector<std::pair<int, int> > >' to 'const std::vector<std::vector<std::pair<long long int, int> > >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/11/vector:67,
                 from dungeons.h:1,
                 from dungeons.cpp:1:
/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 = std::vector<std::pair<long long int, int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, 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 'std::vector<std::vector<std::pair<int, int> > >' to 'std::vector<std::vector<std::pair<long long int, 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 = std::vector<std::pair<long long int, int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, 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 'std::vector<std::vector<std::pair<int, int> > >' to 'std::initializer_list<std::vector<std::pair<long long int, int> > >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~