Submission #1008451

#TimeUsernameProblemLanguageResultExecution timeMemory
1008451nickolasarapidisCombo (IOI18_combo)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int N){
	string S;
	char first;

	char buttons[4] = {'A', 'B', 'X', 'Y'};

	for(int i = 0; i < 4; i++){
		if(press("" + buttons[i]) > 0){
			S.push_back(buttons[i]);
			first = buttons[i];
			break;
		}
	}

	for(int i = 0; i < 4; i++){
		if(buttons[i] != first and press(S + buttons[i]) > 0){
			S += buttons[i];
			if(S.size() < 3){
				i = 0;
			}
		}
	}

	return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:26: warning: 'first' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |   if(buttons[i] != first and press(S + buttons[i]) > 0){
      |      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...