답안 #862506

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
862506 2023-10-18T12:10:15 Z KK_1729 Memory (IOI10_memory) C++17
컴파일 오류
0 ms 0 KB
#include "grader.h"
#include "memory.h"
#include <bits/stdc++.h>
using namespace std;

void play() {
   int i;
   char a, b;
   map<char, vector<int>> x;
   for (int i = 1; i <= 50; i++){
      a = faceup(i);
      x[a].pb(i);
   }

   for (auto c: x){
      faceup(x[c][0]);
      faceup(x[c][1]);
   }
}

Compilation message

memory.cpp: In function 'void play()':
memory.cpp:12:12: error: 'std::map<char, std::vector<int> >::mapped_type' {aka 'class std::vector<int>'} has no member named 'pb'
   12 |       x[a].pb(i);
      |            ^~
memory.cpp:16:15: error: no match for 'operator[]' (operand types are 'std::map<char, std::vector<int> >' and 'std::pair<const char, std::vector<int> >')
   16 |       faceup(x[c][0]);
      |               ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from memory.cpp:3:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::vector<int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::vector<int> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<int>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = char]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::pair<const char, std::vector<int> >' to 'const key_type&' {aka 'const char&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = char; _Tp = std::vector<int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::vector<int> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<int>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = char]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::pair<const char, std::vector<int> >' to 'std::map<char, std::vector<int> >::key_type&&' {aka 'char&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
memory.cpp:17:15: error: no match for 'operator[]' (operand types are 'std::map<char, std::vector<int> >' and 'std::pair<const char, std::vector<int> >')
   17 |       faceup(x[c][1]);
      |               ^
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from memory.cpp:3:
/usr/include/c++/10/bits/stl_map.h:492:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char; _Tp = std::vector<int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::vector<int> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<int>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = char]'
  492 |       operator[](const key_type& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:492:34: note:   no known conversion for argument 1 from 'std::pair<const char, std::vector<int> >' to 'const key_type&' {aka 'const char&'}
  492 |       operator[](const key_type& __k)
      |                  ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_map.h:512:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](std::map<_Key, _Tp, _Compare, _Alloc>::key_type&&) [with _Key = char; _Tp = std::vector<int>; _Compare = std::less<char>; _Alloc = std::allocator<std::pair<const char, std::vector<int> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::vector<int>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = char]'
  512 |       operator[](key_type&& __k)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_map.h:512:29: note:   no known conversion for argument 1 from 'std::pair<const char, std::vector<int> >' to 'std::map<char, std::vector<int> >::key_type&&' {aka 'char&&'}
  512 |       operator[](key_type&& __k)
      |                  ~~~~~~~~~~~^~~
memory.cpp:7:8: warning: unused variable 'i' [-Wunused-variable]
    7 |    int i;
      |        ^
memory.cpp:8:12: warning: unused variable 'b' [-Wunused-variable]
    8 |    char a, b;
      |            ^