Detalii evaluare #51366576

Rezumat problemă

#2629 h3

Tocmai ai primit cadou de ziua ta un șir de numere naturale a[1], a[2], …, a[n]. Ca să te simți împlinit, trebuie să determini lungimea maximă a unei secvențe cu proprietatea că oricare două valori din secvență sunt distincte. Determină lungimea maximă cerută și anul viitor vei mai primi un șir!

Detalii

Problema h3 Operații I/O tastatură/ecran
Limita timp 0.8 secunde Limita memorie Total: 128 MB / Stivă 8 MB
Id soluție #51366576 Utilizator Ioniță Albert (Ionita_Albert_2006)
Fișier h3.cpp Dimensiune 705 B
Data încărcării 10 Iunie 2024, 21:43 Scor / rezultat Eroare de compilare

Evaluare


Mesaj compilare

h3.cpp:4:1: error: 'cin' does not name a type
 cin>>n;

 ^
h3.cpp:5:8: error: array bound is not an integer constant before ']' token
 int a[n],max,tot_max=0,ok1=0,b[n],j,m=n;

        ^
h3.cpp:5:33: error: array bound is not an integer constant before ']' token
 int a[n],max,tot_max=0,ok1=0,b[n],j,m=n;

                                 ^
h3.cpp: In function 'int ok()':
h3.cpp:8:9: error: expected ';' before 'j'
         j=0;

         ^
h3.cpp:9:9: error: reference to 'max' is ambiguous
         max=0;

         ^
h3.cpp:5:10: note: candidates are: int max
 int a[n],max,tot_max=0,ok1=0,b[n],j,m=n;

          ^
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from h3.cpp:1:
/usr/include/c++/4.8/bits/stl_algobase.h:260:5: note:                 template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note:                 template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
h3.cpp:11:19: error: 'i' was not declared in this scope
             if(j!=i && a[i]==a[j]){

                   ^
h3.cpp:11:24: error: 'a' was not declared in this scope
             if(j!=i && a[i]==a[j]){

                        ^
h3.cpp:13:17: error: reference to 'max' is ambiguous
                 max--;

                 ^
h3.cpp:5:10: note: candidates are: int max
 int a[n],max,tot_max=0,ok1=0,b[n],j,m=n;

          ^
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from h3.cpp:1:
/usr/include/c++/4.8/bits/stl_algobase.h:260:5: note:                 template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note:                 template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
h3.cpp:15:13: error: reference to 'max' is ambiguous
             max++;

             ^
h3.cpp:5:10: note: candidates are: int max
 int a[n],max,tot_max=0,ok1=0,b[n],j,m=n;

          ^
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from h3.cpp:1:
/usr/include/c++/4.8/bits/stl_algobase.h:260:5: note:                 template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note:                 template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
h3.cpp: In function 'int main()':
h3.cpp:22:14: error: 'a' was not declared in this scope
         cin>>a[i];

              ^
h3.cpp:26:9: error: 'b' was not declared in this scope
         b[i]=a[i];

         ^
h3.cpp:26:14: error: 'a' was not declared in this scope
         b[i]=a[i];

              ^
h3.cpp:29:19: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
         while(ok!=1){

                   ^
h3.cpp:30:20: warning: the address of 'int ok()' will never be NULL [-Waddress]
             if(ok==0)m--;

                    ^
h3.cpp:31:21: error: reference to 'max' is ambiguous
             else if(max>tot_max){

                     ^
h3.cpp:5:10: note: candidates are: int max
 int a[n],max,tot_max=0,ok1=0,b[n],j,m=n;

          ^
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from h3.cpp:1:
/usr/include/c++/4.8/bits/stl_algobase.h:260:5: note:                 template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note:                 template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
h3.cpp:32:25: error: reference to 'max' is ambiguous
                 tot_max=max;

                         ^
h3.cpp:5:10: note: candidates are: int max
 int a[n],max,tot_max=0,ok1=0,b[n],j,m=n;

          ^
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from h3.cpp:1:
/usr/include/c++/4.8/bits/stl_algobase.h:260:5: note:                 template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note:                 template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^

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 h3 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ă.