Submission #380849

#TimeUsernameProblemLanguageResultExecution timeMemory
380849fl0rianCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>

using namespace std;

string lets[4]={"A","B","X","Y"};

std::string guess_sequence(int N) {
    string ans="";

    int dontUse=-1;
    int found=0;
    int i=0;

    for(int i=0;i<4&&dontUse==-1;i++)
        if(press(lets[i]))
            dontUse=i;

    ans+=lets[dontUse];

    for(int i=1;i<N;i++){
        found=0;
        for(int j=0;j<4 && !found;j++)
            if(dontUse!=j && press(ans + lets[j])==i+1 ){
                ans+=lets[j];
                found=1;
            }
    }

    cout<<ans;

    return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:18:12: error: 'press' was not declared in this scope
   18 |         if(press(lets[i]))
      |            ^~~~~
combo.cpp:26:30: error: 'press' was not declared in this scope
   26 |             if(dontUse!=j && press(ans + lets[j])==i+1 ){
      |                              ^~~~~
combo.cpp:32:5: error: 'cout' was not declared in this scope
   32 |     cout<<ans;
      |     ^~~~
combo.cpp:5:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    4 | #include <string>
  +++ |+#include <iostream>
    5 | 
combo.cpp:15:9: warning: unused variable 'i' [-Wunused-variable]
   15 |     int i=0;
      |         ^