Submission #1014481

#TimeUsernameProblemLanguageResultExecution timeMemory
1014481nisanduuCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string guess_sequence(int n){
    vector<char> av;
    for(ll i=0;i<26;i++){
        char x = ('a'+i);
        string tmp = to_string(x);
        if(press(x)==1){
            av.push_back(x);
        }
    }
    if(av.size()==1){
        string f = "";
        for(ll i=0;i<3;i++){
            f+=av[0];
        }
        return f;
    }else if(av.size()==1){
        string f1 = "",f2 = "";
        f1 += av[0];
        f1 += av[0];
        f1 += av[1];
        f2 += av[0];
        f2 += av[1];
        f2 += av[1];
        sort(f1.begin(),f1.end());
        sort(f2.begin(),f2.end());
        do{
            if(press(f1)==3){
                return f1;
            }
        }while(next_permutation(f1.begin(),f1.end()));
        do{
            if(press(f2)==3){
                return f2;
            }
        }while(next_permutation(f2.begin(),f2.end()));
    }else{
        string f1 = "";
        f1 += av[0];
        f1 += av[1];
        f1 += av[2];
        sort(f1.begin(),f1.end());
        do{
            if(press(f1)==3){
                return f1;
            }
        }while(next_permutation(f1.begin(),f1.end()));
    }
}

// int main()
// {
//     guess_sequence(4);

//     return 0;
// }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:17:18: error: could not convert 'x' from 'char' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   17 |         if(press(x)==1){
      |                  ^
      |                  |
      |                  char
combo.cpp:13:18: warning: control reaches end of non-void function [-Wreturn-type]
   13 |     vector<char> av;
      |                  ^~