제출 #204388

#제출 시각아이디문제언어결과실행 시간메모리
204388my99n콤보 (IOI18_combo)C++14
5 / 100
2 ms248 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

int n;
string ans;

char c[] = "ABXYABXY";
int s = 0;
void g(string S1, string S2, string S3);
void f(string S) {
  if (n <= S.size()) return void (ans = S);
  int coin = press(S+c[s+2]+c[s+2]+S+c[s+3]+c[s+3]+S+c[s+2]+c[s+1]);
  if (coin == S.size()) f(S+c[s+1]);
  if (coin == S.size()+1) g(S+c[s+2]+c[s+3], S+c[s+3]+c[s+2], S+c[s+3]+c[s+1]);
  if (coin == S.size()+2) g(S+c[s+3]+c[s+3], S+c[s+2]+c[s+2], S+c[s+2]+c[s+1]);
}
void g(string S1, string S2, string S3) {
  // cout << "g " << S1 << ' ' << S2 << ' ' << S3 << endl;
  // assert S1.size() == S2.size() == S3.size()
  int coin = press(S3);
  if (coin == S3.size()) f(S3);
  if (coin == S3.size()-1) f(S2);
  if (coin == S3.size()-2) f(S1);
}

string guess_sequence(int N) {
  n = N;
  string S = "";
  int a = press("AB");
  int b = press("AX");
  if (a and b) S = "A", s = 0;
  if (a and !b) S = "B", s = 1;
  if (!a and b) S = "X", s = 2;
  if (!a and !b) S = "Y", s = 3;
  f(S);
  // cout << ans << endl;
  string realans = "";
  for (int i = 0; i < n; i++) realans += ans[i];
  // cout << realans << endl;
  return realans;
}

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

combo.cpp: In function 'void f(std::string)':
combo.cpp:12:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   if (n <= S.size()) return void (ans = S);
      |       ~~^~~~~~~~~~~
combo.cpp:14:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   if (coin == S.size()) f(S+c[s+1]);
      |       ~~~~~^~~~~~~~~~~
combo.cpp:15:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   if (coin == S.size()+1) g(S+c[s+2]+c[s+3], S+c[s+3]+c[s+2], S+c[s+3]+c[s+1]);
      |       ~~~~~^~~~~~~~~~~~~
combo.cpp:16:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |   if (coin == S.size()+2) g(S+c[s+3]+c[s+3], S+c[s+2]+c[s+2], S+c[s+2]+c[s+1]);
      |       ~~~~~^~~~~~~~~~~~~
combo.cpp: In function 'void g(std::string, std::string, std::string)':
combo.cpp:22:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |   if (coin == S3.size()) f(S3);
      |       ~~~~~^~~~~~~~~~~~
combo.cpp:23:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |   if (coin == S3.size()-1) f(S2);
      |       ~~~~~^~~~~~~~~~~~~~
combo.cpp:24:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |   if (coin == S3.size()-2) f(S1);
      |       ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...