Submission #152326

#TimeUsernameProblemLanguageResultExecution timeMemory
152326nicolaalexandraCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <cstring>
#include "combo.h"
using namespace std;

//string s(""), p("");
//int n;
/*int press (string p){ /// asta e query-ul
    int sol;
    cout<<"query "<<p<<endl;
    cin>>sol;
    return sol;
}*/
string guesss_sequence (int n){
    
    string s("");
    string v("");
    /// mai intai trb sa aflu primul caracter
    string c("ABXY");

    int first;
    v += "AB";
    if (press(v) == 0){ /// stiu clar ca e X sau Y
        v.clear(); v = "X";
        if (press(v)){ /// stiu sigur ca e X
            s += "X";
            first = 2;
        } else {
            s += "Y";
            first = 3;
        }
    } else {
        v.clear(); v = "A";
        if (press(v)){
            s += "A";
            first = 0;
        } else {
            s += "B";
            first = 2;
        }}
    /// acum determin cele 3 caractere pe care le mai am de pus
    int ch1,ch2,ch3;
    for (int j=0,pas=0;j<4;j++){
        if (j == first)
            continue;
        pas++;
        if (pas == 1) ch1 = j;
        if (pas == 2) ch2 = j;
        if (pas == 3) ch3 = j;
    }
    for (int i=1;i<n;i++){
        v.clear();
        v += s, v += c[ch1];
        v += s, v += c[ch2], v += c[ch1];
        v += s, v += c[ch2], v += c[ch2];
        v += s, v += c[ch2], v += c[ch3];
        int val = press (v);
        if (val == i){
            s += c[ch3];
            continue;
        }
        if (val == i+1)
            s += c[ch1];
        else s += c[ch2];
    }

    return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guesss_sequence(int)':
combo.cpp:56:40: warning: 'ch3' may be used uninitialized in this function [-Wmaybe-uninitialized]
   56 |         v += s, v += c[ch2], v += c[ch3];
      |                                        ^
combo.cpp:54:27: warning: 'ch2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |         v += s, v += c[ch2], v += c[ch1];
      |                           ^
combo.cpp:53:27: warning: 'ch1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   53 |         v += s, v += c[ch1];
      |                           ^
/usr/bin/ld: /tmp/ccQBPggy.o: in function `main':
grader.cpp:(.text.startup+0x4c): undefined reference to `guess_sequence[abi:cxx11](int)'
collect2: error: ld returned 1 exit status