제출 #1034758

#제출 시각아이디문제언어결과실행 시간메모리
1034758DeathIsAwe콤보 (IOI18_combo)C++14
100 / 100
20 ms1884 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { vector<char> letters; string p = ""; string ptemp = ""; int temp = press("AB"); if (temp == 2) { p += 'A'; } else if (temp == 1) { temp = press("A"); if (temp == 1) { p += 'A'; } else { p += 'B'; } } else { temp = press("X"); if (temp == 1) { p += 'X'; } else { p += 'Y'; } } if ('A' != p[0]) { letters.push_back('A'); } if ('B' != p[0]) { letters.push_back('B'); } if ('X' != p[0]) { letters.push_back('X'); } if ('Y' != p[0]) { letters.push_back('Y'); } if (n == 1) { return p; } while (p.size() < n-1) { ptemp = ""; for (int i=0;i<3;i++) { ptemp += p; ptemp += letters[0]; ptemp += letters[i]; } ptemp += p; ptemp += letters[1]; temp=press(ptemp); if (temp == p.size()) { p += letters[2]; } else if (temp == p.size()+1) { p += letters[1]; } else { p += letters[0]; } } ptemp = p + letters[0]; if (press(ptemp) == n) { p += letters[0]; return p; } else { ptemp = p + letters[1]; if (press(ptemp) == n) { p += letters[1]; return p; } else { p += letters[2]; return p; } } }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |   while (p.size() < n-1) {
      |          ~~~~~~~~~^~~~~
combo.cpp:56:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     if (temp == p.size()) {
      |         ~~~~~^~~~~~~~~~~
combo.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     } else  if (temp == p.size()+1) {
      |                 ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...