Detalii evaluare #57670792

Rezumat problemă

Definim o expresie ca fiind un șir de caractere e care respectă una dintre următoarele:

  • e = "x";
  • e reprezintă un număr natural (constantă); (ex. e ∊ {"1", "2"; "200"; ...})
  • e = "[e1,e2]" sau e = "(e1,e2)", unde e1, e2 sunt (sub-)expresii. Aici, (•, •) semnifică cel mai mare
    divizor comun a două numere, iar [•,•] semnifică cel mai mic multiplu comun a două numere. De exemplu, avem că (6, 8) = 2, [6, 8] = 24.

Dându-se o expresie e și două numere naturale a, b, să se calculeze eval(e, a) + eval(e, a+1) + ... + eval(e, b). Rezultatul se va afișa modulo 1.000.000.007.

ONSEPI, 2021, clasa a X-a

Fișiere Pracsiu Dan (dnprx) Tamio-Vesa Nakajima, Lucian Bicsi concurs

Detalii

Problema Expresii Operații I/O expresii.in/expresii.out
Limita timp 0.5 secunde Limita memorie Total: 256 MB / Stivă 8 MB
Id soluție #57670792 Utilizator Luca Bogdan (bogdan14789)
Fișier expresii.cpp Dimensiune 3.00 KB
Data încărcării 09 Aprilie 2025, 19:59 Scor / rezultat Eroare de compilare

Evaluare

Mesaj compilare

expresii.cpp: In function 'void parse(char*&)':
expresii.cpp:23:9: error: 'Type' was not declared in this scope
         Type op = (*p == '(') ? GCD : LCM;

         ^
expresii.cpp:23:14: error: expected ';' before 'op'
         Type op = (*p == '(') ? GCD : LCM;

              ^
expresii.cpp:29:25: error: 'op' was not declared in this scope
         cmds.push_back({op});

                         ^
expresii.cpp:29:28: error: no matching function for call to 'std::vector<Command>::push_back(<brace-enclosed initializer list>)'
         cmds.push_back({op});

                            ^
expresii.cpp:29:28: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from expresii.cpp:3:
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Command; _Alloc = std::allocator<Command>; std::vector<_Tp, _Alloc>::value_type = Command]
       push_back(const value_type& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const Command&}'
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = Command; _Alloc = std::allocator<Command>; std::vector<_Tp, _Alloc>::value_type = Command]
       push_back(value_type&& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<Command>::value_type&& {aka Command&&}'
expresii.cpp:33:25: error: 'PUSH_X' was not declared in this scope
         cmds.push_back({PUSH_X});

                         ^
expresii.cpp:33:32: error: no matching function for call to 'std::vector<Command>::push_back(<brace-enclosed initializer list>)'
         cmds.push_back({PUSH_X});

                                ^
expresii.cpp:33:32: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from expresii.cpp:3:
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Command; _Alloc = std::allocator<Command>; std::vector<_Tp, _Alloc>::value_type = Command]
       push_back(const value_type& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const Command&}'
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = Command; _Alloc = std::allocator<Command>; std::vector<_Tp, _Alloc>::value_type = Command]
       push_back(value_type&& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<Command>::value_type&& {aka Command&&}'
expresii.cpp:48:25: error: 'PUSH_CONST' was not declared in this scope
         cmds.push_back({PUSH_CONST, f});

                         ^
expresii.cpp:48:39: error: no matching function for call to 'std::vector<Command>::push_back(<brace-enclosed initializer list>)'
         cmds.push_back({PUSH_CONST, f});

                                       ^
expresii.cpp:48:39: note: candidates are:
In file included from /usr/include/c++/4.8/vector:64:0,
                 from expresii.cpp:3:
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Command; _Alloc = std::allocator<Command>; std::vector<_Tp, _Alloc>::value_type = Command]
       push_back(const value_type& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:901:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const Command&}'
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = Command; _Alloc = std::allocator<Command>; std::vector<_Tp, _Alloc>::value_type = Command]
       push_back(value_type&& __x)
       ^
/usr/include/c++/4.8/bits/stl_vector.h:919:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<Command>::value_type&& {aka Command&&}'
expresii.cpp: In function 'int main()':
expresii.cpp:93:18: error: 'PUSH_CONST' was not declared in this scope
             case PUSH_CONST:

                  ^
expresii.cpp:96:18: error: 'PUSH_X' was not declared in this scope
             case PUSH_X:

                  ^
expresii.cpp:99:18: error: 'GCD' was not declared in this scope
             case GCD:

                  ^
expresii.cpp:106:27: error: expected unqualified-id before '[' token
                 for(auto& [p, e] : a)

                           ^
expresii.cpp:106:27: error: expected ';' before '[' token
expresii.cpp:106:31: error: 'e' was not declared in this scope
                 for(auto& [p, e] : a)

                               ^
expresii.cpp: In lambda function:
expresii.cpp:106:34: error: expected '{' before ':' token
                 for(auto& [p, e] : a)

                                  ^
expresii.cpp: In function 'int main()':
expresii.cpp:106:34: error: could not convert '<lambda closure object>main()::__lambda0{p}' from 'main()::__lambda0' to 'bool'
expresii.cpp:106:34: error: expected ';' before ':' token
expresii.cpp:106:34: error: expected primary-expression before ':' token
expresii.cpp:106:34: error: expected ')' before ':' token
expresii.cpp:106:34: error: expected primary-expression before ':' token
expresii.cpp:106:34: error: expected ';' before ':' token
expresii.cpp:111:18: error: 'LCM' was not declared in this scope
             case LCM:

                  ^
expresii.cpp:118:27: error: expected unqualified-id before '[' token
                 for(auto& [p, e] : b)

                           ^
expresii.cpp:118:27: error: expected ';' before '[' token
expresii.cpp:118:31: error: 'e' was not declared in this scope
                 for(auto& [p, e] : b)

                               ^
expresii.cpp: In lambda function:
expresii.cpp:118:34: error: expected '{' before ':' token
                 for(auto& [p, e] : b)

                                  ^
expresii.cpp: In function 'int main()':
expresii.cpp:118:34: error: could not convert '<lambda closure object>main()::__lambda1{p}' from 'main()::__lambda1' to 'bool'
expresii.cpp:118:34: error: expected ';' before ':' token
expresii.cpp:118:34: error: expected primary-expression before ':' token
expresii.cpp:118:34: error: expected ')' before ':' token
expresii.cpp:118:34: error: expected primary-expression before ':' token
expresii.cpp:118:34: error: expected ';' before ':' token
expresii.cpp:91:19: warning: enumeration value 'PUSH_CONST' not handled in switch [-Wswitch]
             switch(cmd.type)

                   ^
expresii.cpp:91:19: warning: enumeration value 'PUSH_X' not handled in switch [-Wswitch]
expresii.cpp:91:19: warning: enumeration value 'GCD' not handled in switch [-Wswitch]
expresii.cpp:91:19: warning: enumeration value 'LCM' not handled in switch [-Wswitch]
expresii.cpp:126:19: error: expected unqualified-id before '[' token
         for(auto& [p, e] : st.back())

                   ^
expresii.cpp:126:19: error: expected ';' before '[' token
expresii.cpp:126:23: error: 'e' was not declared in this scope
         for(auto& [p, e] : st.back())

                       ^
expresii.cpp: In lambda function:
expresii.cpp:126:26: error: expected '{' before ':' token
         for(auto& [p, e] : st.back())

                          ^
expresii.cpp: In function 'int main()':
expresii.cpp:126:26: error: could not convert '<lambda closure object>main()::__lambda2{p}' from 'main()::__lambda2' to 'bool'
expresii.cpp:126:26: error: expected ';' before ':' token
expresii.cpp:126:26: error: expected primary-expression before ':' token
expresii.cpp:126:26: error: expected ')' before ':' token
expresii.cpp:126:26: error: expected primary-expression before ':' token
expresii.cpp:126:26: error: expected ';' before ':' token
expresii.cpp:127:28: error: 'i' was not declared in this scope
             for(int i = 0; i < e; i++)

                            ^
expresii.cpp:127:32: error: 'e' was not declared in this scope
             for(int i = 0; i < e; i++)

                                ^
expresii.cpp:127:38: error: expected ';' before ')' token
             for(int i = 0; i < e; i++)

                                      ^

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

Du-te sus!