Submission #398815

#TimeUsernameProblemLanguageResultExecution timeMemory
398815mshandilyaCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> std::string guess_sequence(int N) { std::string S, p, query; std::vector<char> knownstr; char start; int preknown = 0, score; while(preknown<n) { string p(knownstr.begin(), knownstr.end()); if(preknown==0) { score = press("AB"); if(score){ score = press("A"); if(score) start = 'A'; else start = 'B'; } else{ score = press("X"); if(score) start = 'X'; else start = 'Y'; } knownstr.push_back(start); preknown++; } else if(preknown==N-1) { query = p + "AB"; score = press(query); if(score==preknown+1) { score = press(p + "A"); if(score==preknown+1) knownstr.push_back('A'); else knownstr.push_back('B'); } else { score = press(p + "X"); if(score==preknown+1) knownstr.push_back('X'); else knownstr.push_back('Y'); } preknown++; } else { switch(start) { case 'A': query = p + "BB" + p + "BX" + p + "BY" + p + "X"; score = press(query); if(score==preknown+2) knownstr.push_back('B'); else if(score==preknown+1) knownstr.push_back('X'); else knownstr.push_back('Y'); break; case 'B': query = p + "AA" + p + "AX" + p + "AY" + p + "X"; score = press(query); if(score==preknown+2) knownstr.push_back('A'); else if(score==preknown+1) knownstr.push_back('X'); else knownstr.push_back('Y'); break; case 'X': query = p + "AA" + p + "AB" + p + "AY" + p + "B"; score = press(query); if(score==preknown+2) knownstr.push_back('A'); else if(score==preknown+1) knownstr.push_back('B'); else knownstr.push_back('Y'); break; case 'Y': query = p + "AA" + p + "AB" + p + "AX" + p + "B"; score = press(query); if(score==preknown+2) knownstr.push_back('A'); else if(score==preknown+1) knownstr.push_back('B'); else knownstr.push_back('X'); break; } preknown++; } } string S(knownstr.begin(), knownstr.end()); return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:18: error: 'n' was not declared in this scope
    8 |   while(preknown<n) {
      |                  ^
combo.cpp:9:5: error: 'string' was not declared in this scope; did you mean 'std::string'?
    9 |     string p(knownstr.begin(), knownstr.end());
      |     ^~~~~~
      |     std::string
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note: 'std::string' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
combo.cpp:94:3: error: 'string' was not declared in this scope; did you mean 'std::string'?
   94 |   string S(knownstr.begin(), knownstr.end());
      |   ^~~~~~
      |   std::string
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note: 'std::string' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~