#4786
Lordul John a decis că a venit vremea să însămânțeze terenul său. Terenul a fost împărțit în parcele organizate în N
linii, pe fiecare linie fiind câte N
parcele pătrate, fiecare cu suprafața de un metru pătrat. Liniile au fost numerotate de sus în jos de la 1
la N
, iar coloanele de la stânga la dreapta de la 1
la N
. Fiind un aviator pasionat, a folosit avionul său pentru a survola terenul în vederea însămânțării. La final, după însămânțare, Lordul John dorește să împrejmuiască cu gard parcelele însămânțate, pentru a le separa de cele rămase neînsămânțate sau de marginea terenului.
1. Determinați numărul semințelor care sunt aruncate.
2. Determinați numărul de parcele care sunt însămânțate.
3. Determinați lungimea gardului care trebuie să separe suprafețele însămânțate de cele neînsămânțate sau de marginea terenului.
OJI 2025, clasa a 7-a
Problema | teren1 | Operații I/O |
![]() teren.in /teren.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #57569777 | Utilizator | |
Fișier | teren1.cpp | Dimensiune | 1.53 KB |
Data încărcării | 05 Aprilie 2025, 11:37 | Scor / rezultat | Eroare de compilare |
teren1.cpp:14:8: error: 'int j1' redeclared as different kind of symbol int i1,j1,i2,j2; ^ In file included from /usr/include/features.h:374:0, from /usr/include/i386-linux-gnu/c++/4.8/bits/os_defines.h:39, from /usr/include/i386-linux-gnu/c++/4.8/bits/c++config.h:426, from /usr/include/c++/4.8/iosfwd:38, from /usr/include/c++/4.8/ios:38, from /usr/include/c++/4.8/istream:38, from /usr/include/c++/4.8/fstream:38, from teren1.cpp:1: /usr/include/i386-linux-gnu/bits/mathcalls.h:238:1: error: previous declaration of 'double j1(double)' __MATHCALL (j1,, (_Mdouble_)); ^ teren1.cpp: In function 'void solve_1()': teren1.cpp:21:27: error: invalid operands of types 'int' and 'double(double)throw ()' to binary 'operator-' ans_1+=std::abs(j2-j1); ^ teren1.cpp:22:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] }else if(j1 == j2){ ^ teren1.cpp: In function 'void solve_2()': teren1.cpp:34:35: error: no matching function for call to 'min(double (&)(double)throw (), int&)' for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ teren1.cpp:34:35: note: candidates are: 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/istream:38, from /usr/include/c++/4.8/fstream:38, from teren1.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:193:5: note: template<class _Tp> const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/4.8/bits/stl_algobase.h:193:5: note: template argument deduction/substitution failed: teren1.cpp:34:35: note: deduced conflicting types for parameter 'const _Tp' ('double(double)throw ()' and 'int') for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from teren1.cpp:1: /usr/include/c++/4.8/bits/stl_algobase.h:239:5: note: template<class _Tp, class _Compare> const _Tp& std::min(const _Tp&, const _Tp&, _Compare) min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algobase.h:239:5: note: template argument deduction/substitution failed: teren1.cpp:34:35: note: deduced conflicting types for parameter 'const _Tp' ('double(double)throw ()' and 'int') for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from teren1.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h:4221:5: note: template<class _Tp> _Tp std::min(std::initializer_list<_Tp>) min(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4221:5: note: template argument deduction/substitution failed: teren1.cpp:34:35: note: mismatched types 'std::initializer_list<_Tp>' and 'double (*)(double)throw ()' for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from teren1.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h:4226:5: note: template<class _Tp, class _Compare> _Tp std::min(std::initializer_list<_Tp>, _Compare) min(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4226:5: note: template argument deduction/substitution failed: teren1.cpp:34:35: note: mismatched types 'std::initializer_list<_Tp>' and 'double (*)(double)throw ()' for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ teren1.cpp:34:54: error: no matching function for call to 'max(double (&)(double)throw (), int&)' for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ teren1.cpp:34:54: note: candidates are: 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/istream:38, from /usr/include/c++/4.8/fstream:38, from teren1.cpp:1: /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) ^ /usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template argument deduction/substitution failed: teren1.cpp:34:54: note: deduced conflicting types for parameter 'const _Tp' ('double(double)throw ()' and 'int') for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ 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/istream:38, from /usr/include/c++/4.8/fstream:38, from teren1.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:260:5: note: template argument deduction/substitution failed: teren1.cpp:34:54: note: deduced conflicting types for parameter 'const _Tp' ('double(double)throw ()' and 'int') for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from teren1.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template<class _Tp> _Tp std::max(std::initializer_list<_Tp>) max(initializer_list<_Tp> __l) ^ /usr/include/c++/4.8/bits/stl_algo.h:4231:5: note: template argument deduction/substitution failed: teren1.cpp:34:54: note: mismatched types 'std::initializer_list<_Tp>' and 'double (*)(double)throw ()' for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ In file included from /usr/include/c++/4.8/algorithm:62:0, from teren1.cpp:3: /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template<class _Tp, class _Compare> _Tp std::max(std::initializer_list<_Tp>, _Compare) max(initializer_list<_Tp> __l, _Compare __comp) ^ /usr/include/c++/4.8/bits/stl_algo.h:4236:5: note: template argument deduction/substitution failed: teren1.cpp:34:54: note: mismatched types 'std::initializer_list<_Tp>' and 'double (*)(double)throw ()' for(int i = std::min(j1,j2);i<=std::max(j1,j2);i+=1){ ^ teren1.cpp:40:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] }else if(j1 == j2){ ^ teren1.cpp:42:25: error: invalid types 'int [1001][double(double)throw ()]' for array subscript if(mat[i][j1] == 0){ ^ teren1.cpp:44:26: error: invalid types 'int [1001][double(double)throw ()]' for array subscript mat[i][j1]=1; ^ teren1.cpp:51:15: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] if(j1>j2){d2=-1;} ^ teren1.cpp:52:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] while(i1<=i2 && j1<=j2){ ^ teren1.cpp:54:26: error: invalid types 'int [1001][double(double)throw ()]' for array subscript if(mat[i1][j1]==0){ ^ teren1.cpp:56:27: error: invalid types 'int [1001][double(double)throw ()]' for array subscript mat[i1][j1]=1; ^ teren1.cpp:60:15: warning: pointer to a function used in arithmetic [-Wpointer-arith] j1+=d2; ^ teren1.cpp:60:15: error: assignment of function 'double j1(double)' teren1.cpp:60:15: error: cannot convert 'double (*)(double)throw ()' to 'double(double)throw ()' in assignment teren1.cpp: In function 'int main()': teren1.cpp:74:11: error: cannot bind 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&' in>>i1>>j1>>i2>>j2; ^ In file included from /usr/include/c++/4.8/fstream:38:0, from teren1.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 = double(double)throw ()]' operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema teren1 face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
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ă.