Language: C++


#include<iostream>
#include<map>

int main()
{
    map<string, bool> dict;
    int n;
    string x, y;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        if(x == "insert")
            dict[x] = 1;
        else
        {
            if(dict[y] == 1)
                cout << "yes" << endl;
            else cout << "no" << endl;
        }
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:7:5: error: 'map' was not declared in this scope
    7 |     map<string, bool> dict;
      |     ^~~
a.cc:7:5: note: suggested alternatives:
In file included from /usr/include/c++/14/map:63,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_map.h:102:11: note:   'std::map'
  102 |     class map
      |           ^~~
/usr/include/c++/14/map:89:13: note:   'std::pmr::map'
   89 |       using map
      |             ^~~
a.cc:7:9: error: 'string' was not declared in this scope
    7 |     map<string, bool> dict;
      |         ^~~~~~
a.cc:7:9: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:7:17: error: expected primary-expression before 'bool'
    7 |     map<string, bool> dict;
      |                 ^~~~
a.cc:9:11: error: expected ';' before 'x'
    9 |     string x, y;
      |           ^~
      |           ;
a.cc:10:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   10 |     cin >> n;
      |     ^~~
      |     std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:13:16: error: 'x' was not declared in this scope
   13 |         cin >> x >> y;
      |                ^
a.cc:13:21: error: 'y' was not declared in this scope
   13 |         cin >> x >> y;
      |                     ^
a.cc:15:13: error: 'dict' was not declared in this scope
   15 |             dict[x] = 1;
      |             ^~~~
a.cc:18:16: error: 'dict' was not declared in this scope
   18 |             if(dict[y] == 1)
      |                ^~~~
a.cc:19:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   19 |                 cout << "yes" << endl;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:19:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   19 |                 cout << "yes" << endl;
      |                                  ^~~~
      |                                  std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:20:18: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   20 |             else cout << "no" << endl;
      |                  ^~~~
      |                  std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:20:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   20 |             else cout << "no" << endl;
      |                                  ^~~~
      |                                  std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~