제출 #1015267

#제출 시각아이디문제언어결과실행 시간메모리
1015267TroySerCombo (IOI18_combo)C++17
30 / 100
22 ms852 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {

	string currPerm = "ABXY";
	char firsty;
	for (int i = 0; i < currPerm.size(); i++) {
		if (press(currPerm.substr(i,1)) == 1) {
			firsty = currPerm[i];
			break;
		}
	}

	string currString = "";
	currString += firsty;

	string lol;
	char prevTested = 'Z';
	int diffy;

	for (int i = 1; i < N; i += diffy) {
		for (int j = 0; j < currPerm.size(); j++) {

			if (currPerm[j] == firsty || currPerm[j] == prevTested)
				continue;
			
			lol = "";
			for (int k = i; k < N; k++) lol += currPerm[j];

			int res = press(currString + lol);
			if (res > currString.size()) {
				diffy = res - currString.size();
				prevTested = currPerm[j];
				for (int l = 0; l < diffy; l++) {
					currString += prevTested;
				}
				break;
			}

		}
	}

	return currString;
}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for (int i = 0; i < currPerm.size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~~~
combo.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   for (int j = 0; j < currPerm.size(); j++) {
      |                   ~~^~~~~~~~~~~~~~~~~
combo.cpp:33:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |    if (res > currString.size()) {
      |        ~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:23:27: warning: 'diffy' may be used uninitialized in this function [-Wmaybe-uninitialized]
   23 |  for (int i = 1; i < N; i += diffy) {
      |                         ~~^~~~~~~~
combo.cpp:26:30: warning: 'firsty' may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |    if (currPerm[j] == firsty || currPerm[j] == prevTested)
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...