Submission #1271567

#TimeUsernameProblemLanguageResultExecution timeMemory
1271567MateiKing80A Light Inconvenience (CEOI23_light)C++20
0 / 100
1099 ms525848 KiB
#include "light.h"
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define int ll

vector<int> active;
int n;

void prepare() {
	active.push_back(1);
	n = 1;
}

void recalc(int p) {
	int pos = n;
	vector<int> nactive;
	while (pos >= 0) {
		int ps = -1;
		for (int pas = 1 << 20; pas; pas >>= 1)
			if (ps + pas < (int)active.size() && active[ps + pas] < pos)
				ps += pas;
		if (active[ps] + p >= pos) {
			nactive.push_back(pos);
		} else {
			nactive.push_back(pos = active[ps + 1]);
		}
		pos = max(2 * pos - n - 2, 0ll);
	}
	if (nactive.back() != 1)
		nactive.push_back(1);
	reverse(nactive.begin(), nactive.end());
	active = nactive;
}

pair<int, vector<int>> join(int p) {
	n += p;
	recalc(p);
	return {p, active};
}

pair<int, vector<int>> leave(int p) {
	n -= p;
	recalc(p);
	return {p, active};
}

Compilation message (stderr)

In file included from /usr/include/c++/13/vector:62,
                 from light.h:1,
                 from light.cpp:1:
In static member function 'static constexpr _Up* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(_Tp*, _Tp*, _Up*) [with _Tp = long long int; _Up = long long int; bool _IsMove = false]',
    inlined from 'constexpr _OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = long long int*; _OI = long long int*]' at /usr/include/c++/13/bits/stl_algobase.h:506:30,
    inlined from 'constexpr _OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = long long int*; _OI = long long int*]' at /usr/include/c++/13/bits/stl_algobase.h:533:42,
    inlined from 'constexpr _OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = long long int*; _OI = long long int*]' at /usr/include/c++/13/bits/stl_algobase.h:540:31,
    inlined from 'constexpr _OI std::copy(_II, _II, _OI) [with _II = long long int*; _OI = long long int*]' at /usr/include/c++/13/bits/stl_algobase.h:633:7,
    inlined from 'static _ForwardIterator std::__uninitialized_copy<true>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = long long int*; _ForwardIterator = long long int*]' at /usr/include/c++/13/bits/stl_uninitialized.h:147:27,
    inlined from '_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = long long int*; _ForwardIterator = long long int*]' at /usr/include/c++/13/bits/stl_uninitialized.h:185:15,
    inlined from 'constexpr _ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, allocator<_Tp>&) [with _InputIterator = long long int*; _ForwardIterator = long long int*; _Tp = long long int]' at /usr/include/c++/13/bits/stl_uninitialized.h:373:37,
    inlined from 'constexpr 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>]' at /usr/include/c++/13/bits/vector.tcc:257:35,
    inlined from 'void recalc(ll)' at light.cpp:35:11:
/usr/include/c++/13/bits/stl_algobase.h:437:30: warning: 'void* __builtin_memmove(void*, const void*, long unsigned int)' reading between 9 and 9223372036854775807 bytes from a region of size 8 [-Wstringop-overread]
  437 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/c++allocator.h:33,
                 from /usr/include/c++/13/bits/allocator.h:46,
                 from /usr/include/c++/13/vector:63:
In member function '_Tp* std::__new_allocator<_Tp>::allocate(size_type, const void*) [with _Tp = long long int]',
    inlined from 'constexpr _Tp* std::allocator< <template-parameter-1-1> >::allocate(std::size_t) [with _Tp = long long int]' at /usr/include/c++/13/bits/allocator.h:198:40,
    inlined from 'static constexpr _Tp* std::allocator_traits<std::allocator<_Up> >::allocate(allocator_type&, size_type) [with _Tp = long long int]' at /usr/include/c++/13/bits/alloc_traits.h:482:28,
    inlined from 'constexpr std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' at /usr/include/c++/13/bits/stl_vector.h:381:33,
    inlined from 'constexpr std::_Vector_base<_Tp, _Alloc>::pointer std::_Vector_base<_Tp, _Alloc>::_M_allocate(std::size_t) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' at /usr/include/c++/13/bits/stl_vector.h:378:7,
    inlined from 'constexpr void std::vector<_Tp, _Alloc>::_M_realloc_insert(iterator, _Args&& ...) [with _Args = {long long int}; _Tp = long long int; _Alloc = std::allocator<long long int>]' at /usr/include/c++/13/bits/vector.tcc:459:44,
    inlined from 'constexpr std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {long long int}; _Tp = long long int; _Alloc = std::allocator<long long int>]' at /usr/include/c++/13/bits/vector.tcc:123:21,
    inlined from 'constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' at /usr/include/c++/13/bits/stl_vector.h:1299:21,
    inlined from 'void recalc(ll)' at light.cpp:33:20:
/usr/include/c++/13/bits/new_allocator.h:151:55: note: source object of size 8 allocated by 'operator new'
  151 |         return static_cast<_Tp*>(_GLIBCXX_OPERATOR_NEW(__n * sizeof(_Tp)));
      |                                                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...