제출 #897355

#제출 시각아이디문제언어결과실행 시간메모리
897355honanhphong콤보 (IOI18_combo)C++14
5 / 100
1 ms596 KiB
#include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define faster ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; using lli = long long; using ld = long double; using pii = pair <int, int>; mt19937_64 Rand(chrono::steady_clock::now().time_since_epoch().count()); const int maxn = 1e6 + 1000; const int mod = 1e9 + 7; int press(string p); string guess_sequence(int N) { string s = ""; string p = "ABXY"; char start; char cs[maxn]; if(press("A")) s = "A"; else if(press("B")) s = "B"; else if(press("X")) s = "X"; else s = "Y"; if (s[0] == 'A') { cs[0] = 'B'; cs[1] = 'X'; cs[2] = 'Y'; } else if (s[0] == 'B') { cs[0] = 'A'; cs[1] = 'X'; cs[2] = 'Y'; } else if (s[0] == 'X') { cs[0] = 'A'; cs[1] = 'B'; cs[2] = 'Y'; } else if (s[0] == 'Y') { cs[0] = 'A'; cs[1] = 'B'; cs[2] = 'X'; } while (s.length() < N - 1) { lli guess = press(s + cs[0] + cs[0] + s + cs[0] + cs[1] + s + cs[0] + cs[2] + s + cs[1]); if (guess == s.size() + 2) s += cs[0]; else if (guess == s.size() + 1) s += cs[1]; else s += cs[2]; } if (press(s + cs[0]) == N) return s + cs[0]; else if (press(s + cs[1]) == N) return s + cs[1]; else if (press(s + cs[2]) == N) return s + cs[2]; return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:40:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |     while (s.length() < N - 1)
      |            ~~~~~~~~~~~^~~~~~~
combo.cpp:43:19: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         if (guess == s.size() + 2) s += cs[0];
      |             ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:44:24: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |         else if (guess == s.size() + 1) s += cs[1];
      |                  ~~~~~~^~~~~~~~~~~~~~~
combo.cpp:21:10: warning: unused variable 'start' [-Wunused-variable]
   21 |     char start;
      |          ^~~~~
combo.cpp:47:23: warning: 'cs[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   47 |     if (press(s + cs[0]) == N) return s + cs[0];
      |                       ^
combo.cpp:49:28: warning: 'cs[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   49 |     else if (press(s + cs[2]) == N) return s + cs[2];
      |                            ^
combo.cpp:48:28: warning: 'cs[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |     else if (press(s + cs[1]) == N) return s + cs[1];
      |                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...