Good evening CodeForces,today I tried solving https://oj.uz/problem/view/JOI16_selling_rna. My code has a very weird behaviour. To start, compiling in C++20 takes so long that I guess oj.uz marks it as compilation error. The same code gets AC in C++17 (and compiles instantly ion my machine). See here:↵
↵
https://oj.uz/submission/1277541↵
↵
↵
https://oj.uz/submission/1277540↵
↵
Another weird behavior I encountered while implementing is if you switch the vector<int> nds; with set<int> nds; in the Node struct, and change the push_back's with insert's, it causes an infinite loop I wasn't able to put my finger on. Also if one compiles the set solution with glibcxx, the following error message is produced (which I'm unable to use to my advantage)↵
↵
<spoiler summary="Spoiler">↵
↵
~~~~~↵
/usr/include/c++/13/debug/safe_iterator.h:298:↵
In function:↵
gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::reference ↵
gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::operator*() ↵
const [with _Iterator = std::_Rb_tree_const_iterator<long long int>; ↵
_Sequence = std::debug::set<long long int>; _Category = ↵
std::forward_iterator_tag; reference = const long long int&]↵
↵
Error: attempt to dereference a past-the-end iterator.↵
↵
Objects involved in the operation:↵
iterator "this" @ 0x7ffc5d7fbeb0 {↵
type = std::_Rb_tree_const_iterator<long long> (constant iterator);↵
state = past-the-end;↵
references sequence with type 'std::debug::set<long long, std::less<long long>, std::allocator<long long> >' @ 0x581c1076de90↵
}↵
Aborted (core dumped)↵
~~~~~↵
↵
</spoiler>↵
↵
Please help me since I had a similar problem with c++20 before at an important exam (I had compilation TLE on cms on a very simple code which I dont have access to rn)↵
↵
↵
↵
https://oj.uz/submission/1277541↵
↵
↵
https://oj.uz/submission/1277540↵
↵
Another weird behavior I encountered while implementing is if you switch the vector<int> nds; with set<int> nds; in the Node struct, and change the push_back's with insert's, it causes an infinite loop I wasn't able to put my finger on. Also if one compiles the set solution with glibcxx, the following error message is produced (which I'm unable to use to my advantage)↵
↵
<spoiler summary="Spoiler">↵
↵
~~~~~↵
/usr/include/c++/13/debug/safe_iterator.h:298:↵
In function:↵
gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::reference ↵
gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::operator*() ↵
const [with _Iterator = std::_Rb_tree_const_iterator<long long int>; ↵
_Sequence = std::debug::set<long long int>; _Category = ↵
std::forward_iterator_tag; reference = const long long int&]↵
↵
Error: attempt to dereference a past-the-end iterator.↵
↵
Objects involved in the operation:↵
iterator "this" @ 0x7ffc5d7fbeb0 {↵
type = std::_Rb_tree_const_iterator<long long> (constant iterator);↵
state = past-the-end;↵
references sequence with type 'std::debug::set<long long, std::less<long long>, std::allocator<long long> >' @ 0x581c1076de90↵
}↵
Aborted (core dumped)↵
~~~~~↵
↵
</spoiler>↵
↵
Please help me since I had a similar problem with c++20 before at an important exam (I had compilation TLE on cms on a very simple code which I dont have access to rn)↵
↵
↵




