Submission #1185078

#TimeUsernameProblemLanguageResultExecution timeMemory
1185078nikaa123Combo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> #using namespace std; std::string guess_sequence(int N) { int c; char v0; c = press("AB"); if (c) { c = press("B"); if (c) v0 = 'B'; else v0 = 'A'; } else{ c = press("X"); if (c) { v0 = 'X' } else { v0 = 'Y'; } } vector <char> v; if (v0 != 'A') v.pb('A'); if (v0 != 'B') v.pb('B'); if (v0 != 'Y') v.pb('Y'); if (v0 != 'X') v.pb('X'); string S = ""+v0; for (int i = 2; i <= n-1; i++) { string NS = S+v[0]+v[0]+S+v[0]+v[1]+S+v[0]+v[2]+S+v[1]; c = press(NS); if (c == i+1) { S = S + v[1]; } else if (c == i+2) { S = S+ v[0]; } else { S = S + v[2]; } } return S; }

Compilation message (stderr)

combo.cpp:3:2: error: invalid preprocessing directive #using
    3 | #using namespace std;
      |  ^~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:13: error: expected ';' before '}' token
   16 |     v0 = 'X'
      |             ^
      |             ;
   17 |    }  else {
      |    ~         
combo.cpp:21:3: error: 'vector' was not declared in this scope
   21 |   vector <char> v;
      |   ^~~~~~
combo.cpp:21:3: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from combo.cpp:2:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from combo.cpp:2:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
combo.cpp:21:11: error: expected primary-expression before 'char'
   21 |   vector <char> v;
      |           ^~~~
combo.cpp:22:18: error: 'v' was not declared in this scope; did you mean 'v0'?
   22 |   if (v0 != 'A') v.pb('A');
      |                  ^
      |                  v0
combo.cpp:23:18: error: 'v' was not declared in this scope; did you mean 'v0'?
   23 |   if (v0 != 'B') v.pb('B');
      |                  ^
      |                  v0
combo.cpp:24:18: error: 'v' was not declared in this scope; did you mean 'v0'?
   24 |   if (v0 != 'Y') v.pb('Y');
      |                  ^
      |                  v0
combo.cpp:25:18: error: 'v' was not declared in this scope; did you mean 'v0'?
   25 |   if (v0 != 'X') v.pb('X');
      |                  ^
      |                  v0
combo.cpp:27:3: error: 'string' was not declared in this scope
   27 |   string S = ""+v0;
      |   ^~~~~~
combo.cpp:27:3: note: suggested alternatives:
In file included from /usr/include/c++/11/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/11/bits/stringfwd.h:79:33: note:   'std::string'
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/11/string:67:11: note:   'std::pmr::string'
   67 |     using string    = basic_string<char>;
      |           ^~~~~~
combo.cpp:29:24: error: 'n' was not declared in this scope
   29 |   for (int i = 2; i <= n-1; i++) {
      |                        ^
combo.cpp:30:11: error: expected ';' before 'NS'
   30 |     string NS = S+v[0]+v[0]+S+v[0]+v[1]+S+v[0]+v[2]+S+v[1];
      |           ^~~
      |           ;
combo.cpp:31:15: error: 'NS' was not declared in this scope; did you mean 'N'?
   31 |     c = press(NS);
      |               ^~
      |               N
combo.cpp:33:7: error: 'S' was not declared in this scope
   33 |       S = S + v[1];
      |       ^
combo.cpp:33:15: error: 'v' was not declared in this scope
   33 |       S = S + v[1];
      |               ^
combo.cpp:35:7: error: 'S' was not declared in this scope
   35 |       S = S+ v[0];
      |       ^
combo.cpp:35:14: error: 'v' was not declared in this scope
   35 |       S = S+ v[0];
      |              ^
combo.cpp:37:7: error: 'S' was not declared in this scope
   37 |       S = S + v[2];
      |       ^
combo.cpp:37:15: error: 'v' was not declared in this scope
   37 |       S = S + v[2];
      |               ^
combo.cpp:41:10: error: 'S' was not declared in this scope
   41 |   return S;
      |          ^