제출 #154062

#제출 시각아이디문제언어결과실행 시간메모리
154062nthoangCombo (IOI18_combo)C++11
0 / 100
1 ms256 KiB
#include <bits/stdc++.h>

#ifndef LOCAL
#include "combo.h"
#endif

#ifdef LOCAL
#include "/Users/nth842002/Library/debug.h"
int press(string p) { }
int main() { }
#endif

using namespace std;

const string moves = "ABXY";

string guess_sequence(int n) {
  srand(time(0));
  string s;
  s.resize(n);
  for (int i = 0; i < 4; i++) {
    string t;
    t += moves[i];
    if (press(t) == 1) {
      s[0] = moves[i];
      break;
    }
  }
  string avail;
  for (int i = 0; i < 4; i++) {
    if (moves[i] != s[0]) {
      avail += moves[i];
    }
  }
  string cur;
  cur += s[0];
  for (int i = 1; i < n; i++) {
    random_shuffle(avail.begin(), avail.end());
    for (int j = 0; j < 2; j++) {
      cur += avail[j];
      if (press(cur) == i + 1) {
        break;
      }
      cur.pop_back();
    }
    if (cur.length() == i) {
      cur += avail[2];
    }
  }
  assert(s.length() == n);
  return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |     if (cur.length() == i) {
      |         ~~~~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp:50:21: 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.length() == n);
      |          ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...