Detalii evaluare #34340865

Rezumat problemă

#511 KSort

Se dă un vector cu n elemente, numere naturale și un număr k. Ordonați crescător primele k elemente ale vectorului și descrescător ultimele n-k elemente.

Detalii

Problema KSort Operații I/O tastatură/ecran
Limita timp 0.1 secunde Limita memorie Total: 64 MB / Stivă 8 MB
Id soluție #34340865 Utilizator Colibasanu Andreea (Andreea2006329)
Fișier ksort.cpp Dimensiune 326 B
Data încărcării 29 Ianuarie 2022, 20:05 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

ksort.cpp: In function 'int main()':
ksort.cpp:8:13: error: cannot bind 'std::istream {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&'
     cin>>a[i];

             ^
In file included from /usr/include/c++/4.8/sstream:38:0,
                 from /usr/include/c++/4.8/complex:45,
                 from /usr/include/c++/4.8/ccomplex:38,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from ksort.cpp:1:
/usr/include/c++/4.8/istream:872:5: error:   initializing argument 1 of 'std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _CharT = char; _Traits = std::char_traits<char>; _Tp = int [1001]]'
     operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x)
     ^
In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0,
                 from /usr/include/c++/4.8/bits/stl_algobase.h:64,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/sstream:38,
                 from /usr/include/c++/4.8/complex:45,
                 from /usr/include/c++/4.8/ccomplex:38,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from ksort.cpp:1:
/usr/include/c++/4.8/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]':
/usr/include/c++/4.8/bits/stl_algo.h:2211:62:   required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]'
/usr/include/c++/4.8/bits/stl_algo.h:5462:47:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int (*)[1001]]'
ksort.cpp:9:17:   required from here
/usr/include/c++/4.8/bits/stl_algo.h:2140:11: error: array must be initialized with a brace-enclosed initializer
   __val = _GLIBCXX_MOVE(*__i);
           ^
In file included from /usr/include/c++/4.8/algorithm:62:0,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64,
                 from ksort.cpp:1:
/usr/include/c++/4.8/bits/stl_algo.h:2142:17: error: invalid array assignment
        *__first = _GLIBCXX_MOVE(__val);
                 ^
In file included from /usr/include/c++/4.8/bits/stl_pair.h:59:0,
                 from /usr/include/c++/4.8/bits/stl_algobase.h:64,
                 from /usr/include/c++/4.8/bits/char_traits.h:39,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/istream:38,
                 from /usr/include/c++/4.8/sstream:38,
                 from /usr/include/c++/4.8/complex:45,
                 from /usr/include/c++/4.8/ccomplex:38,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:52,
                 from ksort.cpp:1:
/usr/include/c++/4.8/bits/stl_heap.h: In instantiation of 'void std::make_heap(_RAIter, _RAIter) [with _RAIter = int (*)[1001]]':
/usr/include/c++/4.8/bits/stl_algo.h:1933:39:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]'
/usr/include/c++/4.8/bits/stl_algo.h:5308:51:   required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = int (*)[1001]]'
/usr/include/c++/4.8/bits/stl_algo.h:2310:60:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = int (*)[1001]; _Size = int]'
/usr/include/c++/4.8/bits/stl_algo.h:5461:36:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int (*)[1001]]'
ksort.cpp:9:17:   required from here
/usr/include/c++/4.8/bits/stl_heap.h:406:25: error: array must be initialized with a brace-enclosed initializer
    _ValueType __value = _GLIBCXX_MOVE(*(__first + __parent));
                         ^
/usr/include/c++/4.8/bits/stl_heap.h: In instantiation of 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]':
/usr/include/c++/4.8/bits/stl_algo.h:1936:42:   required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = int (*)[1001]]'
/usr/include/c++/4.8/bits/stl_algo.h:5308:51:   required from 'void std::partial_sort(_RAIter, _RAIter, _RAIter) [with _RAIter = int (*)[1001]]'
/usr/include/c++/4.8/bits/stl_algo.h:2310:60:   required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size) [with _RandomAccessIterator = int (*)[1001]; _Size = int]'
/usr/include/c++/4.8/bits/stl_algo.h:5461:36:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int (*)[1001]]'
ksort.cpp:9:17:   required from here
/usr/include/c++/4.8/bits/stl_heap.h:261:28: error: array must be initialized with a brace-enclosed initializer
       _ValueType __value = _GLIBCXX_MOVE(*__result);
                            ^
In file included from /usr/include/c++/4.8/bits/stl_algo.h:61:0,
                 from /usr/include/c++/4.8/algorithm:62,
                 from /usr/include/i386-linux-gnu/c++/4.8/bits/stdc++.h:64,
                 from ksort.cpp:1:
/usr/include/c++/4.8/bits/stl_heap.h:262:17: error: invalid array assignment
       *__result = _GLIBCXX_MOVE(*__first);
                 ^

Cum funcționează evaluarea?

www.pbinfo.ro permite evaluarea a două tipuri de probleme:

  • probleme la care rezolvarea presupune scrierea unui program complet
  • probleme la care rezolvarea presupune scrierea unei secvențe de program - câteva instrucțiuni, o listă de declarații, una sau mai multe funcții, etc.

Problema KSort face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:

  • Programul sursă este compilat folosind compilatorul corespunzător. Dacă în urma compilării se obțin erori sau avertismente, acestea sunt afișate în această pagină.
  • Dacă programul a fost compilat, executabilul obținut va fi rulat, furnizându-i-se unul sau mai multe seturi de date de intrare, în concordanță cu restricțiile specifice problemei. Pentru fiecare set de date se obține un anumit punctaj, în raport cu corectitudinea soluției tale.

Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.