Submission #1012653

#TimeUsernameProblemLanguageResultExecution timeMemory
1012653j_vdd16Combo (IOI18_combo)C++17
100 / 100
21 ms1980 KiB
#include <algorithm> #include <bitset> #include <cstdint> #include <cstring> #include <iostream> #include <limits.h> #include <math.h> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <vector> #include "combo.h" //#define int long long #define loop(X, N) for(int X = 0; X < (N); X++) #define all(V) V.begin(), V.end() #define rall(V) V.rbegin(), V.rend() using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vector<ii>> vvii; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef uint64_t u64; typedef int64_t i64; int press(string p); string guess_sequence(int n) { vector<char> others = { 'A', 'B', 'X', 'Y' }; string guess; if (press("AB")) { if (press("A")) { guess = "A"; others.erase(others.begin() + 0); } else { guess = "B"; others.erase(others.begin() + 1); } } else { if (press("X")) { guess = "X"; others.erase(others.begin() + 2); } else { guess = "Y"; others.erase(others.begin() + 3); } } if (n == 1) return guess; while (guess.size() < size_t(n) - 1) { int result = press((guess + others[0]) + (guess + others[1] + others[0]) + (guess + others[1] + others[1]) + (guess + others[1] + others[2])); if (result == guess.size()) { guess += others[2]; } else if (result == guess.size() + 1) { guess += others[0]; } else { guess += others[1]; } } if (press(guess + others[0] + guess + others[1]) == n) { if (press(guess + others[0]) == n) return guess + others[0]; else return guess + others[1]; } else return guess + others[2]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:76:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |   if (result == guess.size())
      |       ~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:80:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |   else if (result == guess.size() + 1)
      |            ~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...