Submission #333576

# Submission time Handle Problem Language Result Execution time Memory
333576 2020-12-07T05:18:06 Z nicholask Combo (IOI18_combo) C++14
Compilation error
0 ms 0 KB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
char c[4]={'A','B','X','Y'};
string guess_sequence(int n){
	string ans="";
	for (int i=1; i<=n; i++){
		int fc;
		if (i==1){
			if (press("AB")){;
				if (press("A")){
					ans+='A';
					fc=0;
				} else {
					ans+='B';
					fc=1;
				}
			} else {
				if (press("X")){
					ans+='X';
					fc=2;
				} else {
					ans+='Y';
					fc=3;
				}
			}
			continue;
		}
		if (i==n){
			string q=ans;
			q+=c[(fc+1)%4];
			if (press(q)==n) ans+=c[(fc+1)%4];
			else {
				q.pop_back();
				q+=c[(fc+2)%4];
				if (press(q)==n) ans+=c[(fc+2)%4];
				else ans+=c[(fc+3)%4];
			}
			continue;
		}
		string q="";
		q+=ans;
		q+=c[(fc+1)%4];
		q+=c[(fc+1)%4];
		q+=ans;
		q+=c[(fc+1)%4];
		q+=c[(fc+2)%4];
		q+=ans;
		q+=c[(fc+1)%4];
		q+=c[(fc+3)%4];
		q+=ans;
		q+=c[(fc+2)%4];
		int c=press(q);
		if (c==ans.size()+2) ans+=c[(fc+1)%4];
		else if (c==ans.size()+1) ans+=c[(fc+2)%4];
		else ans+=c[(fc+3)%4];
	}
	return ans;
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:54:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   if (c==ans.size()+2) ans+=c[(fc+1)%4];
      |       ~^~~~~~~~~~~~~~
combo.cpp:54:30: error: invalid types 'int[int]' for array subscript
   54 |   if (c==ans.size()+2) ans+=c[(fc+1)%4];
      |                              ^
combo.cpp:55:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   else if (c==ans.size()+1) ans+=c[(fc+2)%4];
      |            ~^~~~~~~~~~~~~~
combo.cpp:55:35: error: invalid types 'int[int]' for array subscript
   55 |   else if (c==ans.size()+1) ans+=c[(fc+2)%4];
      |                                   ^
combo.cpp:56:14: error: invalid types 'int[int]' for array subscript
   56 |   else ans+=c[(fc+3)%4];
      |              ^