Submission #1142386

#TimeUsernameProblemLanguageResultExecution timeMemory
1142386FZ_LaabidiCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int n){
    string p = "";
    set<string> S;
    S.insert("A");
    S.insert("B");
    S.insert("X");
    S.insert("Y");
    string trash = "AB";
    int c = press(trash);
    if(c==1){
        c = press("A");
        if(c==1)p+="A";
        else p+="B";
    }
    else{
        c = press("X");
        if(c==1)p+="X";
        else p+="Y";
    }
    if(n==1)return p;
    S.erase(p);
    // Remaining letters up to the (n-1)th
    int c=0;
    string b,xx,y;
    for (auto x: S){
        if (c == 0) b = x;
        if (c == 1)  xx = x;
        if (c == 2) y = x;
        c++;
    }
    int count = 1;
    for(int i=0; i<n-1; i++){
        string t = p+b+p+xx+y+p+xx+xx+p+xx+b;
        c = press(t);
        if(c==count)p+=y;
        else if(c==count+1)p+=b;
        else p+=xx;
        count++;
    }
    string t = p+xx+p+b;
    c = press(t);
    if(c==n){
        c = press(p+xx);
        if(c==n)p+=xx;
        else p+=b;
    }
    else p+=y;
    return p;

}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:9: error: redeclaration of 'int c'
   27 |     int c=0;
      |         ^
combo.cpp:13:9: note: 'int c' previously declared here
   13 |     int c = press(trash);
      |         ^