제출 #1034716

#제출 시각아이디문제언어결과실행 시간메모리
1034716DeathIsAwe콤보 (IOI18_combo)C++17
5 / 100
1 ms344 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'); } int count; while (p.size() < n-1) { ptemp = ""; count = 0; 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:43:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |   while (p.size() < n-1) {
      |          ~~~~~~~~~^~~~~
combo.cpp:55:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     if (temp == p.size()) {
      |         ~~~~~^~~~~~~~~~~
combo.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     } else  if (temp == p.size()+1) {
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:42:7: warning: variable 'count' set but not used [-Wunused-but-set-variable]
   42 |   int count;
      |       ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...