제출 #986853

#제출 시각아이디문제언어결과실행 시간메모리
986853LucaIlie콤보 (IOI18_combo)C++17
97 / 100
14 ms2212 KiB
#include "combo.h" #include <iostream> using namespace std; char ch[4] = {'A', 'B', 'X', 'Y' }; char alf[3]; string s, g; string guess_sequence( int n ) { int coins, i, first_letter = -1, j, verific; for( i = 0; i < 3; i++ ) { s = ch[i]; if( press(s) == 1 ) first_letter = i; } if( first_letter == -1 ) first_letter = 3; s = ch[first_letter]; j = 0; for( i = 0; i < 4; i++ ) { if( i != first_letter ) { alf[j] = ch[i]; j++; } } for( i = 1; i < n - 1; i++ ) { //cout << s << "\n"; g = s + alf[0] + alf[0] + s + alf[0] + alf[1] + s + alf[0] + alf[2] + s + alf[1]; coins = press( g ); if( coins == i + 2 ) s = s + alf[0]; else if( coins == i + 1 ) s = s + alf[1]; else s = s + alf[2]; } if( n > 1 ) { for (i = 0; i < 2; i++) { if (press(s + alf[i]) == n) { s = s + alf[i]; break; } } if (s.size() < n) s = s + alf[2]; } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |         if (s.size() < n)
      |             ~~~~~~~~~^~~
combo.cpp:10:41: warning: unused variable 'verific' [-Wunused-variable]
   10 |     int coins, i, first_letter = -1, j, verific;
      |                                         ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...