Submission #140251

#TimeUsernameProblemLanguageResultExecution timeMemory
140251Runtime_error_Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB

#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {
    string ans = "";
    if( press("AB") )
        ans += ( press("A") ? 'A' : 'B' );
    else
        ans += ( press("X") ? 'X' : 'Y');

    if(ans[0] != 'A')
        v.push_back('A');
    else if(ans[0] != 'B')
        v.push_back('B');
    else if(ans[0] != 'X')
        v.push_back('X');
    else
        v.push_back('Y');

    for(int i=1;i<N-1;i++){
        string tmp = ans+v[0] + ans+v[1]+v[0] + ans+v[1]+v[1] + ans+v[1]+v[2];
        int res = press(tmp);
        if( res == ans.size() )
            ans += v[2];
        else if( res == ans.size()+2 )
            ans += v[1];
        else
            ans += v[0];
    }
    if( press( ans+v[0] ) == N )
        ans += v[0];
    else if( press( ans+v[1] ) == N)
        ans += v[1];
    else
        ans += v[2];
    return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:14:9: error: 'v' was not declared in this scope
   14 |         v.push_back('A');
      |         ^
combo.cpp:16:9: error: 'v' was not declared in this scope
   16 |         v.push_back('B');
      |         ^
combo.cpp:18:9: error: 'v' was not declared in this scope
   18 |         v.push_back('X');
      |         ^
combo.cpp:20:9: error: 'v' was not declared in this scope
   20 |         v.push_back('Y');
      |         ^
combo.cpp:23:26: error: 'v' was not declared in this scope
   23 |         string tmp = ans+v[0] + ans+v[1]+v[0] + ans+v[1]+v[1] + ans+v[1]+v[2];
      |                          ^
combo.cpp:25:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if( res == ans.size() )
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         else if( res == ans.size()+2 )
      |                  ~~~~^~~~~~~~~~~~~~~
combo.cpp:32:20: error: 'v' was not declared in this scope
   32 |     if( press( ans+v[0] ) == N )
      |                    ^