[HELP NEEDED]: Insane Bug in C++20 Solution
Difference between en3 and en4, changed 4 character(s)
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 on 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> 
nids; with set<int> nids; 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)↵
↵
↵

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English Seferoglu 2025-10-09 21:27:11 4
en3 English Seferoglu 2025-10-09 20:16:35 6
en2 English Seferoglu 2025-10-09 20:16:03 22
en1 English Seferoglu 2025-10-09 20:15:32 1832 Initial revision (published)