Submission #961826

#TimeUsernameProblemLanguageResultExecution timeMemory
961826Gr1senCombo (IOI18_combo)C++17
30 / 100
34 ms1224 KiB
#include "combo.h"
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

#define vi vector<int>
#define vvi vector<vi>

string guess_sequence(int n) {
	string ans = "";
	while (ans.size() < n) {
		string s = ans+"A"+ans+"B";
		while(s.size() < n) s += 'B';
		int k = press(s);
		//cerr << k << " " << s << endl;
		if (k >= ans.size()+1) {
			s = ans+"A";
			while(s.size() < n) s += 'A';
			k = press(s);
			if (k >= ans.size()+1) {
				ans += 'A';
				continue;
			}
			ans += 'B';
			continue;
		}
		s = ans+"X";
		while(s.size() < n) s += 'X';
		k = press(s);
		if (k >= ans.size()+1) {
			ans += 'X';
			continue;
		}
		ans += 'Y';
	}
	//cerr << "ans : " << ans << endl;
	return ans;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |  while (ans.size() < n) {
      |         ~~~~~~~~~~~^~~
combo.cpp:15:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |   while(s.size() < n) s += 'B';
      |         ~~~~~~~~~^~~
combo.cpp:18:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if (k >= ans.size()+1) {
      |       ~~^~~~~~~~~~~~~~~
combo.cpp:20:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |    while(s.size() < n) s += 'A';
      |          ~~~~~~~~~^~~
combo.cpp:22:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |    if (k >= ans.size()+1) {
      |        ~~^~~~~~~~~~~~~~~
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   while(s.size() < n) s += 'X';
      |         ~~~~~~~~~^~~
combo.cpp:32:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   if (k >= ans.size()+1) {
      |       ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...