Submission #1041734

#TimeUsernameProblemLanguageResultExecution timeMemory
1041734kheiraMemory (IOI10_memory)C++14
Compilation error
0 ms0 KiB
#include "grader.h" #include "memory.h" #include <map> #include<bits/stdc++.h> using namespace std; void play(){ map<char,vector<int>> Cards; vector <pair <int,int>> matchedCards; for (int C = 1; C <= 50; ++C){ char letterCard = faceup(C); Cards[letterCard] = faceup(C); if (Cards.find(letterCard) != Cards.end() ) { int previous_letterCard = Cards[letterCard][0]; matchedCards.push_back(make_pair(previous_letterCard, C)); faceup(previous_letterCard); faceup(C); return; } else { Cards[letterCard].pushback(C); } } }

Compilation message (stderr)

memory.cpp: In function 'void play()':
memory.cpp:12:37: error: no match for 'operator=' (operand types are 'std::map<char, std::vector<int> >::mapped_type' {aka 'std::vector<int>'} and 'char')
   12 |         Cards[letterCard] = faceup(C);
      |                                     ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from memory.cpp:4:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'char' to 'const std::vector<int>&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from memory.cpp:4:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'char' to 'std::vector<int>&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'char' to 'std::initializer_list<int>'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
memory.cpp:24:31: error: 'std::map<char, std::vector<int> >::mapped_type' {aka 'class std::vector<int>'} has no member named 'pushback'; did you mean 'push_back'?
   24 |             Cards[letterCard].pushback(C);
      |                               ^~~~~~~~
      |                               push_back