제출 #1034731

#제출 시각아이디문제언어결과실행 시간메모리
1034731DeathIsAwe콤보 (IOI18_combo)C++14
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 = 0; while (p.size() < n-1) { count += 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]; } } if (count > 2*n) { count = 1/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: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) {
      |                 ~~~~~^~~~~~~~~~~~~
combo.cpp:65:14: warning: division by zero [-Wdiv-by-zero]
   65 |     count = 1/0;
      |             ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...