제출 #138384

#제출 시각아이디문제언어결과실행 시간메모리
138384Lawliet콤보 (IOI18_combo)C++14
100 / 100
67 ms600 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; char buttons[] = {'A' , 'B' , 'X' , 'Y'}; int N; string S; string remain; void getFirstLetter() { if( press("AB") >= 1 ) { if(press("A") == 1) S = "A"; else S = "B"; } else { if(press("X") == 1) S = "X"; else S = "Y"; } } string guess_sequence(int n) { N = n; getFirstLetter(); if(N == 1) return S; for(int g = 0 ; g < 4 ; g++) if(buttons[g] != S[0]) remain.push_back( buttons[g] ); for(int g = 1 ; g < N - 1 ; g++) { string cur; for(int h = 0 ; h < 3 ; h++) cur = cur + S + remain[0] + remain[h]; cur = cur + S + remain[1]; int aux = press( cur ); if(aux == S.size()) S = S + remain[2]; if(aux == S.size() + 1) S = S + remain[1]; if(aux >= S.size() + 2) S = S + remain[0]; } if(press(S + remain[0]) == N) return S + remain[0]; if(press(S + remain[1]) == N) return S + remain[1]; return S + remain[2]; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:50:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   if(aux == S.size()) S = S + remain[2];
      |      ~~~~^~~~~~~~~~~
combo.cpp:51:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   if(aux == S.size() + 1) S = S + remain[1];
      |      ~~~~^~~~~~~~~~~~~~~
combo.cpp:52:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   if(aux >= S.size() + 2) S = S + remain[0];
      |      ~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...