Submission #223708

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

*/
#include "combo.h"
using namespace std;

const int mod=1e9 + 7;
#define int long long
const int inf=1e18;
#define pii pair<int, int>
#define f first
#define s second 
#define mp make_pair
#define FOR(i, n) for(int i=1;i<=n;i++)
#define TRACE(x) cerr << #x << " = " << x << endl 
//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 temp=ans;
	temp+="AB";
	int ct=press(temp);
	ct-=ans.size();
	if(ct>0)
	{
		temp.pop_back();
		ct=press(temp);
		ct-=ans.size();
		if(ct>0)
		{
			fc='A';
			ans+="A";
		}
		else
		{
			ans+="B";fc='B';
		}	
	}
	else
	{
		temp.pop_back();temp.pop_back();temp+="X";
		ct=press(temp);ct-=ans.size();
		if(ct>0)
		{
			ans+="X";fc='X';
		}
		else
		{
			ans+="Y";fc='Y';
		}	
	}
}*/

string guess_sequence(int n)
{
	string ans;char fc;
	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];
	}
	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;
		int ct=press(temp);
		if(ct<i) ans+=c3;
		else if(ct==i) ans+=c1;
		else ans+=c2;
	}
//	fl();
	return ans;
}
/*signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//	guess_sequence(5);
//	cout<<"Answer:"<<ans;
}*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(long long int)':
combo.cpp:67:3: warning: 'fc' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |   if(arr[j]==fc) continue;
      |   ^~
/usr/bin/ld: /tmp/ccOrHVqX.o: in function `main':
grader.cpp:(.text.startup+0x4c): undefined reference to `guess_sequence[abi:cxx11](int)'
collect2: error: ld returned 1 exit status