Submission #1067476

#TimeUsernameProblemLanguageResultExecution timeMemory
1067476dostsCombo (IOI18_combo)C++17
91 / 100
19 ms2032 KiB
#include "combo.h"
//Dost SEFEROĞLU
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int MOD = 1e9+7,inf = 2e18;
const int N = 1e5+50;
 
string guess_sequence(int32_t N) {
  string cur;
  vector<char> chars = {'A','B','X','Y'};
  char firstletter = '0';
  random_shuffle(all(chars));
  for (auto it : chars) {
    if (it == chars.back()) continue;
    string ss;
    ss+=it;
    if (press(ss)) {
      firstletter = it;
      break;
    }
  }
  if (firstletter == '0') firstletter = chars.back();
  char alterone = '0',altertwo = '0',alterthree = '0';
  for (auto it : chars) {
    if (it != firstletter) {
      if (alterone == '0') alterone = it;
      else if (altertwo == '0') altertwo = it;
      else if (alterthree == '0') alterthree = it;
    }
  }
  cur+=firstletter;
  for (int i=2;i<=N-1;i++) {
    string presser = cur;
    presser+=altertwo;
    presser+=cur;
    presser+=alterone;
    presser+=altertwo;
    presser+=cur;
    presser+=alterone;
    presser+=alterthree;
    presser+=cur;
    presser+=alterone;
    presser+=alterone;
    int v = press(presser);
    if (v == cur.length()){
      cur+=alterthree;
      continue;
    }
    else if (v == cur.length()+1) {
      cur+=altertwo;
      continue;
    }
    else cur+=alterone;
  }
  char rem = chars.back();
  chars.pop_back();
  random_shuffle(all(chars));
  for (auto it : chars) {
    if (it == firstletter) continue;
    string curr = cur;
    curr+=it;
    if (press(curr) > cur.length()) {
      cur+=it;
      break;
    }
  }
  if (cur.length() != N) cur+=rem;
  return cur;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int32_t)':
combo.cpp:52:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     if (v == cur.length()){
      |         ~~^~~~~~~~~~~~~~~
combo.cpp:56:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     else if (v == cur.length()+1) {
      |              ~~^~~~~~~~~~~~~~~~~
combo.cpp:69:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     if (press(curr) > cur.length()) {
      |         ~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:74:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int32_t' {aka 'int'} [-Wsign-compare]
   74 |   if (cur.length() != N) cur+=rem;
      |       ~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...