Undefined Behaviour

Правка en1, от MasterRayuga, 2022-05-10 19:50:57

Can someone please tell me why my code is showing this type of undefined behavior

here is the first submission which is getting WA on test 2 (when submitted on c++17) & WA on test 5 (when submitted on c++20)

here is the accepted solution The only thing that I have changed here is

        for(int i=0;i<n;i++){
            cin>>arr[i];
            mp1[arr[i]]++;
            if(mp1[arr[i]]>=k){
                s1.insert(arr[i]);
            }
        }

to

        for(int i=0;i<n;i++){
            cin>>arr[i];
            mp1[arr[i]]++;
        }
        for(int i=0;i<n;i++){
            if(mp1[arr[i]]>=k){
                s1.insert(arr[i]);
            }            
        }
Теги c++, undefined behavior

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский MasterRayuga 2022-05-10 19:50:57 898 Initial revision (published)