제출 #648234

#제출 시각아이디문제언어결과실행 시간메모리
648234_petar_b콤보 (IOI18_combo)C++14
100 / 100
35 ms620 KiB
#include "combo.h" #include <bits/stdc++.h> #define MAXN 100010 #define pb push_back #define ll long long #define fi first #define se second #define mp make_pair using namespace std; std::string guess_sequence(int N) { char c[4] = {'A', 'B', 'X', 'Y'}; int coins = press("AB"); std::string S = ""; if (coins >= 1) { coins = press("A"); if (coins == 1) { S += "A"; swap(c[0], c[3]); } else { S += "B"; swap(c[1], c[3]); } } else { coins = press("X"); if (coins == 1) { S += "X"; swap(c[2], c[3]); } else { S += "Y"; } } while(S.size() < N-1) { std::string p = ""; //1 p += S; p += c[0]; //2; p += S; p += c[1]; p += c[0]; //3 p += S; p += c[1]; p += c[1]; //4 p += S; p += c[1]; p += c[2]; coins = press(p); if (coins == S.size()) S += c[2]; else if (coins == S.size() + 1) S += c[0]; else S += c[1]; } if (N == 1) return S; string p = ""; p += S; p += c[0]; coins = press(p); if (coins == N) { S += c[0]; return S; } p = ""; p += S; p += c[1]; coins = press(p); if (coins == N) { S += c[1]; return S; } S += c[2]; return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:43:20: 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(S.size() < N-1)
      |           ~~~~~~~~~^~~~~
combo.cpp:62:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |         if (coins == S.size())
      |             ~~~~~~^~~~~~~~~~~
combo.cpp:64:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         else if (coins == S.size() + 1)
      |                  ~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...