제출 #167122

#제출 시각아이디문제언어결과실행 시간메모리
167122minseo852콤보 (IOI18_combo)C++11
0 / 100
109 ms200 KiB
#include <combo.h> #include <bits/stdc++.h> #include <string> #include <vector> #include <iostream> using namespace std; int countchar[2000] = { 0 }; void countup() { countchar[0] += 1; for (int i = 0; i < 1999; i++) { if (countchar[i] > 2) { countchar[i] = 0; countchar[i + 1] += 1; continue; } break; } } string guess_sequence(int N) { string result; if (press("AB") >= 1) { result = (press("A") == 1 ? "A" : "B"); } else result = (press("X") == 1 ? "X" : "Y"); if (N == 1) return result; vector<string> others = { "A", "B", "X", "Y" }; for (int i = 0; i < 4; i++) if (others[i] == result) { others.erase(others.begin() + i); break; } string check; int size_cnt = 0; int low, high, mid; while (true) { check.clear(); for (int i = 0; i < 4; i++) { check += result; for (int j = 0; j < N-result.size(); j++) { check += others[countchar[j]]; } countup(); } if ((size_cnt = press(check)) > result.size()) { low = 0; high = check.size() - 1; while (true) { mid = (low + high) / 2; if (press(check.substr(low, mid)) == size_cnt) { high = mid; } else { low = mid; } if (check.substr(low, high).size() == size_cnt) { result = check.substr(low, high); break; } } if (result.size() == N) break; } } return result; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:59:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |    for (int j = 0; j < N-result.size(); j++)
      |                    ~~^~~~~~~~~~~~~~~~~
combo.cpp:66:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   if ((size_cnt = press(check)) > result.size())
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:82:40: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   82 |     if (check.substr(low, high).size() == size_cnt)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:89:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   89 |    if (result.size() == N)
      |        ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...