Submission #1024180

#TimeUsernameProblemLanguageResultExecution timeMemory
1024180ksu2009enCombo (IOI18_combo)C++14
100 / 100
25 ms2140 KiB
#include <iostream> #include <vector> #include <string> #include <math.h> #include <cmath> #include <iomanip> #include <cstdio> #include <algorithm> #include <numeric> #include <map> #include <set> #include <queue> #include <stack> #include <deque> #include <bitset> #include <cstring> #include <unordered_map> using namespace std; typedef long long ll; #include "combo.h" //int press(string p){ // // return 0; //} string guess_sequence(int n){ string ans; if(n == 1){ if(press("A")) ans = "A"; else if(press("B")) ans = "B"; else if(press("X")) ans = "X"; else ans = "Y"; return ans; } ll f = press("AB"); if(f == 2) ans = "A"; else if(f == 0){ // x or y if(press("XA") == 0) ans = "Y"; else ans = "X"; } else{ // a or b if(press("AX") == 0) ans = "B"; else ans = "A"; } vector<string> vec, v = {"A", "B", "X", "Y"}; for(auto i: v) if(i != ans) vec.push_back(i); for(int i = 1; i <= n - 2; i++){ string res = ans + vec[0]; res += ans + vec[1] + vec[0]; res += ans + vec[1] + vec[1]; res += ans + vec[1] + vec[2]; ll c = press(res); if(c == ans.size() + 1) ans += vec[0]; else if(c == ans.size() + 2) ans += vec[1]; else ans += vec[2]; } string res = ans + vec[0]; if(press(res) == n) ans += vec[0]; else{ res = ans + vec[1]; if(press(res) == n) ans += vec[1]; else ans += vec[2]; } return ans; }

Compilation message (stderr)

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