제출 #1111415

#제출 시각아이디문제언어결과실행 시간메모리
1111415SalihSahin콤보 (IOI18_combo)C++14
5 / 100
1 ms512 KiB
#include <bits/stdc++.h>
#define pb push_back
#include "combo.h"
using namespace std;
 
std::string guess_sequence(int N) {
  string p = "A", ans = "";
  int c = press(p);
  if(c) ans += 'A';
  p = "B";
  c = press(p);
  if(c && !ans.size()) ans += 'B';
  p = "X";
  c = press(p);
  if(c && !ans.size()) ans += 'X';
  p = "X";
  if(!ans.size()) ans += 'Y';
 
  vector<char> other;
  if(ans == "A"){
    other.pb('B');
    other.pb('X');
    other.pb('Y');
  }
  if(ans == "B"){
    other.pb('A');
    other.pb('X');
    other.pb('Y');
  }
  if(ans == "X"){
    other.pb('B');
    other.pb('A');
    other.pb('Y');
  }
  if(ans == "Y"){
    other.pb('B');
    other.pb('X');
    other.pb('A');
  }
 
  for(int i = 1; i < N-1; i++){
     p = "";
     // don't add other[0]
     p += (ans + other[1]); // just add other[1]
     p += (ans + other[2] + other[0]);
     p += (ans + other[2] + other[1]);
     p += (ans + other[2] + other[2]);
 
     int len = press(p);
 
     if(len == i) ans += other[0];
     else if(len == i + 1) ans += other[1];
     else ans += other[2];
  }
 
  p = ans + other[0];
  c = press(p);
  if(c == N) ans += other[0];
  p = ans + other[1];
  c = press(p);
  if(c == N && ans.size() < N) ans += other[1];
  if(ans.size() < N) ans += other[2];
 
  return ans;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:61:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |   if(c == N && ans.size() < N) ans += other[1];
      |                ~~~~~~~~~~~^~~
combo.cpp:62:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |   if(ans.size() < N) ans += other[2];
      |      ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...