Submission #103813

#TimeUsernameProblemLanguageResultExecution timeMemory
103813beso123Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
/*string a="ABXY";
string pas;
int qu;
int press(string s){
	qu++;
    int r=0;
    string b="";
    for(int k=0;k<pas.size();k++){
        b=b+pas[k];
        if(s.find(b)==-1)
            return r;
            r++;
    }
    return r;
}*/
string guess_sequence(int N){
string s;
int num,i=0;
string b;
s=a[0]+a[1];
if(press(s)==1){
	s=a[0];
	if(press(s)==1){
		b+=s;
		a.erase(0,1);
	}
	else{
		b+=a[1];
		a.erase(1,1);
	}
}
else{
	s=a[2];
	if(press(s)==1){
		b+=s;
		a.erase(2,1);
	}
	else{
		b+=a[3];
		a.erase(3,1);
	}
}
while(b.size()<N-1){
		string c=b+a[0]+b+a[1]+a[0]+b+a[1]+a[2]+b+a[1]+a[1];
		int ps=press(c);
		if(ps==b.size())
		b+=a[2];
		else{
		if(ps==b.size()+1)
		b+=a[0];
		else
		if(ps==b.size()+2)
		b+=a[1];
}
}
i=0;
while(true){

	s=b+a[i];
	num=press(s);

	if(num==b.size()+1){
		b+=a[i];
		break;
	}
	i++;
}
return b;
}
/*int main(){
 cin>>pas;
    string s=guess_sequence(pas.size());
    cout<<s<<' '<<qu;
 
return 0;
 
}*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:23:3: error: 'a' was not declared in this scope
   23 | s=a[0]+a[1];
      |   ^
combo.cpp:46:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 | while(b.size()<N-1){
      |       ~~~~~~~~^~~~
combo.cpp:49:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   if(ps==b.size())
      |      ~~^~~~~~~~~~
combo.cpp:52:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   if(ps==b.size()+1)
      |      ~~^~~~~~~~~~~~
combo.cpp:55:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   if(ps==b.size()+2)
      |      ~~^~~~~~~~~~~~
combo.cpp:65:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |  if(num==b.size()+1){
      |     ~~~^~~~~~~~~~~~