#1058
Puncte1
Andrei se descurcă foarte bine la geometrie şi de aceea născoceşte tot felul de jocuri pe care le testează cu Alexandru, colegul său de bancă. Pentru a pregăti noul joc cu trei niveluri, Andrei desenează pe o foaie de matematică reperul cartezian xOy
şi mai multe puncte distincte. Fiecare punct desenat are atât abscisa x
, cât şi ordonata y
, numere întregi.
La primul nivel, Alexandru determină numărul maxim de puncte (dintre cele desenate) aflate pe una dintre axele sistemului cartezian sau pe o dreaptă paralelă cu una dintre cele două axe.
La al doilea nivel, Alexandru consideră toate punctele desenate a căror abscisă x
şi ordonată y
verifică cel puţin una dintre relaţiile x=y
sau x+y=0
şi apoi calculează câte drepte distincte trec prin cel puţin două dintre aceste puncte.
La al treilea nivel, Alexandru numără şi şterge punctele din 3
în 3
(primul, al 4
-lea, al 7
-lea etc.), începând cu cel mai din stânga punct desenat şi continuând către dreapta. Dacă două sau mai multe puncte au aceeaşi abscisă, el le numără pe acestea de jos în sus (începând de la punctul cu ordonata cea mai mică). Când a ajuns cu număratul la cel mai din dreapta punct continuă cu cel mai din stânga punct rămas.
Alexandru se opreşte cu numărarea şi ştergerea când rămâne un singur punct desenat pe foaie.
Scrieţi un program care citeşte numărul natural nenul N
, apoi cele 2*N
numere întregi ce reprezintă coordonatele celor N
puncte şi determină:
a) NRP
, numărul maxim de puncte (dintre cele desenate) aflate pe una dintre axele sistemului cartezian sau pe o dreaptă paralelă cu una dintre cele două axe;
b) NRD
, numărul de drepte distincte care trec prin cel puţin două dintre punctele desenate a căror abscisa x
şi ordonată y
verifică cel puţin una dintre relaţiile x=y
sau x+y=0
;
c) XP
reprezentând abscisa punctului rămas pe foaie la sfârşitul celui de-al treilea nivel al jocului.
Problema | Puncte1 | Operații I/O |
![]() puncte1.in /puncte1.out
|
---|---|---|---|
Limita timp | 0.8 secunde | Limita memorie |
Total: 32 MB
/
Stivă 32 MB
|
Id soluție | #49331857 | Utilizator | |
Fișier | puncte1.cpp | Dimensiune | 459 B |
Data încărcării | 26 Februarie 2024, 16:47 | Scor / rezultat | Eroare de compilare |
puncte1.cpp: In function 'int main()': puncte1.cpp:9:8: error: 'i' was not declared in this scope for(i=1;i<=n;i++) ^ puncte1.cpp:10:10: error: no match for 'operator>' (operand types are 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' and 'int') { f>>x>y; ^ puncte1.cpp:10:10: note: candidates are: In file included from /usr/include/c++/4.8/bits/stl_algobase.h:64:0, 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from puncte1.cpp:1: /usr/include/c++/4.8/bits/stl_pair.h:233:5: note: template<class _T1, class _T2> constexpr bool std::operator>(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^ /usr/include/c++/4.8/bits/stl_pair.h:233:5: note: template argument deduction/substitution failed: puncte1.cpp:10:11: note: 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' is not derived from 'const std::pair<_T1, _T2>' { f>>x>y; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from puncte1.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:309:5: note: template<class _Iterator> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_Iterator>&) operator>(const reverse_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:309:5: note: template argument deduction/substitution failed: puncte1.cpp:10:11: note: 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>' { f>>x>y; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from puncte1.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:359:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::reverse_iterator<_Iterator>&, const std::reverse_iterator<_IteratorR>&) operator>(const reverse_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:359:5: note: template argument deduction/substitution failed: puncte1.cpp:10:11: note: 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' is not derived from 'const std::reverse_iterator<_Iterator>' { f>>x>y; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from puncte1.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1079:5: note: template<class _IteratorL, class _IteratorR> bool std::operator>(const std::move_iterator<_Iterator>&, const std::move_iterator<_IteratorR>&) operator>(const move_iterator<_IteratorL>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1079:5: note: template argument deduction/substitution failed: puncte1.cpp:10:11: note: 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' is not derived from 'const std::move_iterator<_Iterator>' { f>>x>y; ^ In file included from /usr/include/c++/4.8/bits/stl_algobase.h:67:0, 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/ostream:38, from /usr/include/c++/4.8/iostream:39, from puncte1.cpp:1: /usr/include/c++/4.8/bits/stl_iterator.h:1085:5: note: template<class _Iterator> bool std::operator>(const std::move_iterator<_Iterator>&, const std::move_iterator<_Iterator>&) operator>(const move_iterator<_Iterator>& __x, ^ /usr/include/c++/4.8/bits/stl_iterator.h:1085:5: note: template argument deduction/substitution failed: puncte1.cpp:10:11: note: 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' is not derived from 'const std::move_iterator<_Iterator>' { f>>x>y; ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from puncte1.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2606:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const std::basic_string<_CharT, _Traits, _Alloc>&) operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2606:5: note: template argument deduction/substitution failed: puncte1.cpp:10:11: note: 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' { f>>x>y; ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from puncte1.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2618:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2618:5: note: template argument deduction/substitution failed: puncte1.cpp:10:11: note: 'std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}' is not derived from 'const std::basic_string<_CharT, _Traits, _Alloc>' { f>>x>y; ^ In file included from /usr/include/c++/4.8/string:52:0, from /usr/include/c++/4.8/bits/locale_classes.h:40, from /usr/include/c++/4.8/bits/ios_base.h:41, from /usr/include/c++/4.8/ios:42, from /usr/include/c++/4.8/ostream:38, from /usr/include/c++/4.8/iostream:39, from puncte1.cpp:1: /usr/include/c++/4.8/bits/basic_string.h:2630:5: note: template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const std::basic_string<_CharT, _Traits, _Alloc>&) operator>(const _CharT* __lhs, ^ /usr/include/c++/4.8/bits/basic_string.h:2630:5: note: template argument deduction/substitution failed: puncte1.cpp:10:11: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' { f>>x>y; ^ puncte1.cpp:20:8: error: 'i' was not declared in this scope for(i=1;i<=n) ^ puncte1.cpp:20:16: error: expected ';' before ')' token for(i=1;i<=n) ^ puncte1.cpp:21:21: error: 'sort' was not declared in this scope sort(v1+1,v1+2000); ^ puncte1.cpp:22:7: error: 'v' was not declared in this scope g<<v[2000]; ^ puncte1.cpp:7:50: warning: unused variable 'v3' [-Wunused-variable] { int x,y,v1[2000],v2[2000],n,nr1=0,nr2=0,nr3=0,v3; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Puncte1 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ă.