Submission #582753

#TimeUsernameProblemLanguageResultExecution timeMemory
582753TimDee콤보 (IOI18_combo)C++14
30 / 100
48 ms472 KiB
#include "combo.h"

#include <bits/stdc++.h>
using namespace std;

#define forn(i,n) for (int i=0; i<n; ++i)
#define all(a) a.begin(), a.end()
#define pb(x) push_back(x)

std::string guess_sequence(int N) {
    
  int n=N;
  string s;
  //forn(i,n) s+='*';
  char f;
  if (press("AB")) {
    if (press("A")) {
      f='A';
    } else {
      f='B';
    }
  } else {
    if (press("X")) {
      f='X';
    } else {
      f='Y';
    }
  }

  vector<char> v;
  if (f!='A') v.pb('A'); if (f!='B') v.pb('B'); if (f!='X') v.pb('X'); if (f!='Y') v.pb('Y'); 

  s+=f;
  vector<char> Or;

  while (s.length()!=N) {

    string p=s;
    if (Or.size()) p+=Or[0];
    p+=v[0];
    p+=s;
    if (Or.size()) p+=Or[0];
    p+=v[1];

    int x = press(p);

    if (x==N) {
      string p=s;
      if (Or.size()) p+=Or[0];
      //p+=v[0];
      if (x==press(p+v[0])) return p+v[0];
      else return p+v[1];
    }

    if (x==s.length() && x==p.length()/2-1) {
      if (Or.size()) {
        s+=Or[0];
        Or.clear();
      }
      s+=v[2];
    }
    else if (x>s.length()+Or.size()/2){

      if (Or.size()) s+=Or[0];
      Or.clear();
      Or.pb(v[0]);
      Or.pb(v[1]);
      
    } else if(x>s.length()) {
      if (Or.size()) s+=Or[0];
      s+=v[2];
      Or.clear();
    } else {
      if (Or.size()) s+=Or[1];
      Or.clear();
    }

  }

  return s;

}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   31 |   if (f!='A') v.pb('A'); if (f!='B') v.pb('B'); if (f!='X') v.pb('X'); if (f!='Y') v.pb('Y');
      |   ^~
combo.cpp:31:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   31 |   if (f!='A') v.pb('A'); if (f!='B') v.pb('B'); if (f!='X') v.pb('X'); if (f!='Y') v.pb('Y');
      |                          ^~
combo.cpp:36:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |   while (s.length()!=N) {
      |          ~~~~~~~~~~^~~
combo.cpp:55:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     if (x==s.length() && x==p.length()/2-1) {
      |         ~^~~~~~~~~~~~
combo.cpp:55:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     if (x==s.length() && x==p.length()/2-1) {
      |                          ~^~~~~~~~~~~~~~~~
combo.cpp:62:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     else if (x>s.length()+Or.size()/2){
      |              ~^~~~~~~~~~~~~~~~~~~~~~~
combo.cpp:69:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     } else if(x>s.length()) {
      |               ~^~~~~~~~~~~
combo.cpp:12:7: warning: unused variable 'n' [-Wunused-variable]
   12 |   int n=N;
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...