Submission #223716

#TimeUsernameProblemLanguageResultExecution timeMemory
223716bharat2002Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
/*input

*/

#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
//Trace prints the name of the variable and the value.

int press(string st)
{
	cout<<st<<":";int ret;cin>>ret;return ret;
}
void fl();
string ans;char fc;
string guess_sequence(int n)
{
	
	ans="";char arr[5]={'A', 'B', 'X', 'Y'};
	fl();
	char c1='0', c2='0', c3='0';
	for(int j=0;j<4;j++)
	{
		if(arr[j]==fc) continue;
		if(c1=='0') c1=arr[j];
		else if(c2=='0') c2=arr[j];
		else c3=arr[j];
	}
	assert(c1!='0');assert(c2!='0');assert(c3!='0');
	assert(c1!=c2);assert(c1!=c3);assert(c2!=c3);
	for(int i=2;i<n;i++)
	{
		string temp=ans;temp+=c1;temp+=ans;temp+=c2;temp+=c1;temp+=ans;temp+=c2;temp+=c2;temp+=ans;temp+=c2;temp+=c3;
		assert(temp.size()<=4*n);
		int ct=press(temp);
		if(ct<i) ans+=c3;
		else if(ct==i) ans+=c1;
		else ans+=c2;
	}
	fl();
	return ans;
}
void fl()
{
	string temp=ans;
	temp+="A";temp+=ans;temp+="B";
	string t2;
	int ct=press(temp);
	ct-=ans.size();
	if(ct>0)
	{
		t2=ans;t2+="A";
		ct=press(t2);
		ct-=ans.size();
		if(ct>0)
		{
			fc='A';
			ans+="A";
		}
		else
		{
			ans+="B";fc='B';
		}	
	}
	else
	{
		t2=ans;t2+="X";
		ct=press(t2);ct-=ans.size();
		if(ct>0)
		{
			ans+="X";fc='X';
		}
		else
		{
			ans+="Y";fc='Y';
		}	
	}
}

/*
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	guess_sequence(3);
	cout<<"Answer:"<<ans;
}*/

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:6:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |   assert(temp.size()<=4*n);
      |          ~~~~~~~~~~~^~~~~
/usr/bin/ld: /tmp/cc8iqiUC.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccgjmIvE.o:combo.cpp:(.text+0xc0): first defined here
collect2: error: ld returned 1 exit status