제출 #390698

#제출 시각아이디문제언어결과실행 시간메모리
390698JimmyZJX콤보 (IOI18_combo)C++14
5 / 100
1 ms456 KiB
#include <iostream> #include <fstream> #include <algorithm> #include <cstring> #include <climits> #include <cassert> #include <tuple> #include <queue> #include <stack> #include <vector> #include <map> #include <set> #include <string> #include <unordered_set> #include <unordered_map> using namespace std; typedef long long LL; typedef vector<int> Vi; typedef vector<bool> Vb; typedef vector<vector<int>> Vii; #define forR(i, n) for (int i = 0; i < (n); i++) int press(string p); string guess_sequence(int N) { // step 1: first char first; if (press("AB") >= 1) { if (press("A") == 1) first = 'A'; else first = 'B'; } else { if (press("X") == 1) first = 'X'; else first = 'Y'; } string s; s.append(1, first); set<char> keyset{ 'A','B','X','Y' }; keyset.erase(first); vector<char> ks(keyset.begin(), keyset.end()); for (int i = 1; i <= N - 2; i++) { string q = s + ks[2] + ks[0] + s + ks[2] + ks[1] + s + ks[2] + ks[2] + s + ks[1]; int r = press(q) - s.size(); s.append(1, ks[r]); } if (s.size() < N) { assert(s.size() == N - 1); if (press(s + ks[0]) == N) return s + ks[0]; if (press(s + ks[1]) == N) return s + ks[1]; return s + ks[2]; } } #ifdef TEST_LOCAL string ans = "ABXYY"; int press(string p) { for (int i = ans.size(); i > 0; i--) { if (p.find(ans.substr(0, i)) != string::npos) { return i; } } return 0; } int main() { auto c = guess_sequence(ans.size()); return 0; } #endif

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:49:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |  if (s.size() < N) {
      |      ~~~~~~~~~^~~
In file included from /usr/include/c++/10/cassert:44,
                 from combo.cpp:6:
combo.cpp:50:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |   assert(s.size() == N - 1);
      |          ~~~~~~~~~^~~~~~~~
combo.cpp:39:9: warning: control reaches end of non-void function [-Wreturn-type]
   39 |  string s; s.append(1, first);
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...