Submission #574976

#TimeUsernameProblemLanguageResultExecution timeMemory
574976HackapieCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
 
std::string guess_sequence(int N){
  set<char> s;
  s.insert('A');
  s.insert('B');
  s.insert('X');
  s.insert('Y');
  string res;
  int N;
  cin>>N;
  string check;
  for(int i=1;i<=N;i++){  //cout<<"i:"<<i<<"\n";
    //each i for ith character
    //in first i we have 4 choices 
    //afterthat we have 3 choices always
    char c;
    if(i==1){
        for(auto x:s){
            string aux=res;
            aux+=x;
            int ans=press(aux);
            // cout<<aux<<"\n";
            // int ans;
            // cin>>ans;
            if(ans==i){
                //ok this is part of the string 
                res=aux;
                c=x;
                break;
            }
        }
        if(i==1)s.erase(c);
        for(auto x:s)check+=x;
        // cout<<"pr.size():"<<pr.size()<<"\n";
        // for(int i=0;i<pr.size();i++){
        //     cout<<pr[i]<<" ";
        // }  cout<<"\n";
    }else{
        if(i==N){
            for(auto x:s){
                string aux=res;
                aux+=x;
                int ans=press(aux);
                // cout<<aux<<"\n";
                // int ans;
                // cin>>ans;
                if(ans==i){
                    //ok this is part of the string 
                    res=aux;
                    break;
                }
            }
        }else{
            string ch=res+check[1]+res+check[2]+check[0]+res+check[2]+check[1]+res+check[2]+check[2];
            res+=check[press(ch)-res.size()]; //we are not providing any res+check[0] in query so if 0th then always return 0 similarly we are provinging only next charcater for check[1] so if true always return 1 more and similarly we are providing all possibility of 2nd check so it will always return 2 more if present
            
        }
    }

  }
return res;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:12:7: error: declaration of 'int N' shadows a parameter
   12 |   int N;
      |       ^
combo.cpp:5:32: note: 'int N' previously declared here
    5 | std::string guess_sequence(int N){
      |                            ~~~~^