Submission #633493

#TimeUsernameProblemLanguageResultExecution timeMemory
633493anjamilicevic콤보 (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define IOS {ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back

using namespace std;

vector<char> v={'A', 'B', 'X', 'Y'}, w;

string guess_sequence(int n)
{
    string s="";
    char x;
    
    string p="AB";
    if(press(k))
    {
        x="B";
        if(press("A"))x="A";
    }
    else
    {
        x="Y";
        if(press("X"))x="X";
    }
    
    s+=x;
    
    for(auto u:v)
    {
        if(u!=x)w.pb(u);
    }
    
    while(s.size() < n-1)
    {
        string q=s+w[0]+s+w[1]+w[0]+s+w[1]+w[1]+s+w[1]+w[2];
        int cnt=press(q);
        int vel=s.size();
        if(cnt == vel+1)s+=w[0];
        else if(cnt == vel+2)s+=w[1];
        else s+=w[2];
    }
    
    if(n>1)
    {
        char c=w[2];
        for(int i=0; i<2; i++)
        {
            if(press(s+w[i]) == n)c=w[i]; break;
        }
    }
    
    s+=c;
    
    return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:14: error: 'k' was not declared in this scope
   15 |     if(press(k))
      |              ^
combo.cpp:15:8: error: 'press' was not declared in this scope
   15 |     if(press(k))
      |        ^~~~~
combo.cpp:17:11: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   17 |         x="B";
      |           ^~~
      |           |
      |           const char*
combo.cpp:18:25: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   18 |         if(press("A"))x="A";
      |                         ^~~
      |                         |
      |                         const char*
combo.cpp:22:11: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   22 |         x="Y";
      |           ^~~
      |           |
      |           const char*
combo.cpp:23:25: error: invalid conversion from 'const char*' to 'char' [-fpermissive]
   23 |         if(press("X"))x="X";
      |                         ^~~
      |                         |
      |                         const char*
combo.cpp:33:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |     while(s.size() < n-1)
      |           ~~~~~~~~~^~~~~
combo.cpp:36:17: error: 'press' was not declared in this scope
   36 |         int cnt=press(q);
      |                 ^~~~~
combo.cpp:48:16: error: 'press' was not declared in this scope
   48 |             if(press(s+w[i]) == n)c=w[i]; break;
      |                ^~~~~
combo.cpp:48:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   48 |             if(press(s+w[i]) == n)c=w[i]; break;
      |             ^~
combo.cpp:48:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   48 |             if(press(s+w[i]) == n)c=w[i]; break;
      |                                           ^~~~~
combo.cpp:52:8: error: 'c' was not declared in this scope
   52 |     s+=c;
      |        ^