Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    i learn vector. but have mistakes. i dont know where

    UndefinedBehaviorSanitizer:DEADLYSIGNAL
    ==1==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000002ab1000 (pc 0x0000004256b0 bp 0x000002ab0ff8 sp 0x7ffe65674d90 T1)
    ==1==The signal is caused by a READ memory access.
    ==1==WARNING: invalid path to external symbolizer!
    ==1==WARNING: Failed to use and restart external symbolizer!
    #include
    #include
    using namespace std;

    vector pipe_fix(const vector& nums) {
    //убрать повторения
    vector nums1 = nums;

    for ( vector::iterator i = nums1.begin(); i != nums1.end(); ++i)

    for ( vector<int>::iterator j = i + 1;      j != nums1.end();  ++j)
      if ( *i == *j) {  nums1.erase(j); --j;  }
    

    //и отсортировать
    vector nums2(nums1.size()); // создаем новый вектор, там все будет отсортировано
    int min = nums1[0];
    vector::iterator it_min;
    vector::iterator i = nums1.begin();
    for ( ; i != nums1.end(); ++i)
    {
    for ( vector::iterator j = i+1; j != nums1.end() & i != j; ++j)
    {
    if ( *i < *j & *i <= min) { min = *i; it_min = i;}
    if ( *i > *j & *j <= min) { min = *j; it_min = j; }
    }
    nums2.push_back(min);
    nums1.erase(it_min);
    }

    nums2.push_back( *(nums.begin() ) );// в конец вектора добавляем оставшийся элемент - самый большой

    //далее отсортирован и нет повторений
    vector n;
    n.push_back(nums2[0]);
    for ( int q = 0; nums2[0] + q != *(nums2.end() - 1); ++q)
    n.push_back(nums2[0] + q);

    n.push_back( *(nums2.end() - 1 ));
    return n;
    }

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    WHAT THE PROPLEM?
    In file included from main.cpp:6:
    ./solution.cpp:5:20: warning: comparison of integers of different signs: 'int' and 'std::__cxx11::basic_string<char, std::char_traits, std::allocator >::size_type' (aka 'unsigned long') [-Wsign-compare]
    for(int i = 0; i < str.length() ; ++i)
    ~ ^ ~~~~~~~~~~~~
    ./solution.cpp:12:23: warning: comparison of integers of different signs: 'int' and 'std::__cxx11::basic_string<char, std::char_traits, std::allocator >::size_type' (aka 'unsigned long') [-Wsign-compare]
    for( int i = 0; i < x.length() ; ++i )
    ~ ^ ~~~~~~~~~~
    2 warnings generated.