#1696
Perechi2
Fie un şir a[1]
, a[2]
, …, a[n]
de numere naturale, unde n
este impar. Avem la dispoziţie o singură operaţie admisă şi anume: putem aduna la două poziţii diferite din şir o aceeaşi valoare naturală nenulă.
Cerințe:
ONI 2016, clasa a V-a
Problema | Perechi2 | Operații I/O |
perechi2.in /perechi2.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54953649 | Utilizator | |
Fișier | perechi2.cpp | Dimensiune | 2.06 KB |
Data încărcării | 13 Decembrie 2024, 12:17 | Scor / rezultat | Eroare de compilare |
perechi2.cpp: In function 'int main()': perechi2.cpp:49:26: error: no match for 'operator=' (operand types are 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}' and 'std::pair<const int, int>') if(cnt==1)i=x; ^ perechi2.cpp:49:26: note: candidates are: In file included from /usr/include/c++/4.8/map:60:0, from perechi2.cpp:2: /usr/include/c++/4.8/bits/stl_tree.h:157:12: note: std::_Rb_tree_iterator<std::pair<const int, int> >& std::_Rb_tree_iterator<std::pair<const int, int> >::operator=(const std::_Rb_tree_iterator<std::pair<const int, int> >&) struct _Rb_tree_iterator ^ /usr/include/c++/4.8/bits/stl_tree.h:157:12: note: no known conversion for argument 1 from 'std::pair<const int, int>' to 'const std::_Rb_tree_iterator<std::pair<const int, int> >&' /usr/include/c++/4.8/bits/stl_tree.h:157:12: note: std::_Rb_tree_iterator<std::pair<const int, int> >& std::_Rb_tree_iterator<std::pair<const int, int> >::operator=(std::_Rb_tree_iterator<std::pair<const int, int> >&&) /usr/include/c++/4.8/bits/stl_tree.h:157:12: note: no known conversion for argument 1 from 'std::pair<const int, int>' to 'std::_Rb_tree_iterator<std::pair<const int, int> >&&' perechi2.cpp:50:31: error: no match for 'operator=' (operand types are 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}' and 'std::pair<const int, int>') else if(cnt==2)j=x; ^ perechi2.cpp:50:31: note: candidates are: In file included from /usr/include/c++/4.8/map:60:0, from perechi2.cpp:2: /usr/include/c++/4.8/bits/stl_tree.h:157:12: note: std::_Rb_tree_iterator<std::pair<const int, int> >& std::_Rb_tree_iterator<std::pair<const int, int> >::operator=(const std::_Rb_tree_iterator<std::pair<const int, int> >&) struct _Rb_tree_iterator ^ /usr/include/c++/4.8/bits/stl_tree.h:157:12: note: no known conversion for argument 1 from 'std::pair<const int, int>' to 'const std::_Rb_tree_iterator<std::pair<const int, int> >&' /usr/include/c++/4.8/bits/stl_tree.h:157:12: note: std::_Rb_tree_iterator<std::pair<const int, int> >& std::_Rb_tree_iterator<std::pair<const int, int> >::operator=(std::_Rb_tree_iterator<std::pair<const int, int> >&&) /usr/include/c++/4.8/bits/stl_tree.h:157:12: note: no known conversion for argument 1 from 'std::pair<const int, int>' to 'std::_Rb_tree_iterator<std::pair<const int, int> >&&' perechi2.cpp:54:18: error: 'std::map<int, int>::iterator' has no member named 'second' if(i.second>1) { ^ perechi2.cpp:55:23: error: 'std::map<int, int>::iterator' has no member named 'first' a=b=i.first; ^ perechi2.cpp:57:21: error: 'std::map<int, int>::iterator' has no member named 'first' m[i.first]-=2; ^ perechi2.cpp:60:21: error: 'std::map<int, int>::iterator' has no member named 'first' a=i.first; ^ perechi2.cpp:61:21: error: 'std::map<int, int>::iterator' has no member named 'first' b=j.first; ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Perechi2 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ă.