Submission #792823

#TimeUsernameProblemLanguageResultExecution timeMemory
792823fatemetmhrCombo (IOI18_combo)C++17
5 / 100
1 ms208 KiB
// Be name khode // #include "combo.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define all(x) x.begin(), x.end() #define pb push_back #define fi first #define se second #define mp make_pair typedef long long ll; const int maxn5 = 5e5 + 10; const int lg = 20; string s[4]; char a[4]; std::string guess_sequence(int n) { string c[4] = {"A", "B", "X", "Y"}; shuffle(c, c + 4, rng); if(press(c[0])) s[0] = s[1] = s[2] = s[3] = c[0]; else if(press(c[1])) s[0] = s[1] = s[2] = s[3] = c[1]; else if(press(c[2])) s[0] = s[1] = s[2] = s[3] = c[2]; else if(press(c[3])) s[0] = s[1] = s[2] = s[3] = c[3]; for(int i = 0; i < 4; i++) a[i] = c[i][0]; while(s[0].size() < n){ int keep = s[0].size(); for(int i = 0; i < 4; i++) while(s[i].size() < n) s[i].pb(a[rng() % 4]); string t = s[0] + s[1] + s[2] + s[3]; int k = press(t); for(int i = 0; i < 4; i++) while(s[i].size() > k) s[i].pop_back(); if(k == keep || rng() % 20 == 0){ int mx = 0, val = 0; for(int i = 0; i < 4; i++){ int w = press(s[i]); if(w >= val){ mx = i; val = w; } } for(int i = 0; i < 4; i++) s[i] = s[mx]; } } shuffle(s, s + 4, rng); for(int i = 0; i < 4; i++) if(press(s[i]) == n) return s[i]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:39:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     while(s[0].size() < n){
      |           ~~~~~~~~~~~~^~~
combo.cpp:42:31: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |             while(s[i].size() < n)
      |                   ~~~~~~~~~~~~^~~
combo.cpp:47:31: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |             while(s[i].size() > k)
      |                   ~~~~~~~~~~~~^~~
combo.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
   66 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...