Submission #777546

#TimeUsernameProblemLanguageResultExecution timeMemory
777546NeroZeinCombo (IOI18_combo)C++17
5 / 100
1 ms208 KiB
#include "combo.h"
#include "bits/stdc++.h"
using namespace std; 

string X = "ABXY";

std::string guess_sequence(int N) {
  string p; 
  char first; 
  string tmp = "AB"; 
  if (press(tmp) > 0) {
    tmp = "A";
    if (press(tmp) == 1) {
      first = 'A';
    } else {
      first = 'B';
    }
  } else {
    tmp = 'X';
    if (press(tmp) == 1) {
      first = 'X';
    } else {
      first = 'Y';
    }
  }
  tmp = first;
  p += first;
  vector<string> st;
  for (int i = 0; i < 4; ++i) {
    for (int j = 0; j < 4; ++j) {
      if (X[i] == first || X[j] == first) {
        continue; 
      }
      string t;
      t += X[i];
      t += X[j];
      st.push_back(t); 
    }
  }
  auto ask = [&](string a, string b, string c) {
    string x = p + a + p + b + p + c;
    return press(x); 
  };
  vector<bool> vis(N);
  for (int i = 1; i + 1 < N; ) {
    int x = ask(st[0], st[1], st[3]);
    if (x == 2 + p.size()) {
      vis[i] = vis[i + 1] = true;
      int y = press(p + st[0]);
      if (y == 2 + p.size()) {
        p += st[0];
      } else if (y == 1 + p.size()) {
        p += st[1];
      } else {
        p += st[3];
      }
      i += 2; 
    } else if (x == 1 + p.size()) {
      vis[i] = vis[i + 1] = true;
      int y = press(p + st[4]);
      if (y == 2 + p.size()) {
        p += st[4];
      } else if (y == 1 + p.size()) {
        p += st[5];
      } else {
        p += st[2]; 
      }
      i += 2; 
    } else {
      vis[i] = true; 
      p += st.back()[0]; 
      i++;
    }
  }
  if (!vis.back()) {
    int cnt = 1;
    for (int i = 0; i < 4; ++i) {
      if (X[i] == first) continue;
      if (cnt == 3 || press(p + X[i]) == N) {
        p += X[i];
        return p; 
      }
      cnt++; 
    }
  }
  return p;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     if (x == 2 + p.size()) {
      |         ~~^~~~~~~~~~~~~~~
combo.cpp:50:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |       if (y == 2 + p.size()) {
      |           ~~^~~~~~~~~~~~~~~
combo.cpp:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |       } else if (y == 1 + p.size()) {
      |                  ~~^~~~~~~~~~~~~~~
combo.cpp:58:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     } else if (x == 1 + p.size()) {
      |                ~~^~~~~~~~~~~~~~~
combo.cpp:61:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |       if (y == 2 + p.size()) {
      |           ~~^~~~~~~~~~~~~~~
combo.cpp:63:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |       } else if (y == 1 + p.size()) {
      |                  ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...