Submission #471588

#TimeUsernameProblemLanguageResultExecution timeMemory
471588Cross_RatioCombo (IOI18_combo)C++14
100 / 100
42 ms548 KiB
#include <bits/stdc++.h> //#include "combo.h" using namespace std; int press(string); string guess_sequence(int N) { int isA = press("AB"); string st; char c; if(isA) { int isB = press("B"); if(isB) st = "B"; else st = "A"; } else { int isD = press("X"); if(isD) st = "X"; else st = "Y"; } c = st[0]; char x, y, z; char C[3]; int cnt = 0; set<char> S; S.insert('A'); S.insert('B'); S.insert('X'); S.insert('Y'); S.erase(c); for(set<char>::iterator iter = S.begin();iter != S.end();iter++) { C[cnt++] = *iter; } x = C[0]; y = C[1]; z = C[2]; while(st.length() < N) { if(st.length() != N - 1) { string s1 = st + x + x + st + x + y + st + y + x; int k = press(s1) - st.length(); if(k == 0) { st = st + z; } else if(k == 1) { string s2 = st + y + y; int k2 = press(s2) - st.length(); if(k2 == 0) { st = st + x + z; } else if(k2 == 1) { st = st + y + z; } else st = st + y + y; } else { string s2 = st + x + x; int k3 = press(s2) - st.length(); if(k3 == 0) { st = st + y + x; } else if(k3 == 1) { st = st + x + y; } else st = st + x + x; } } else { string s2 = st + x + st + y; int k2 = press(s2) - st.length(); if(k2 == 0) st = st + z; else { string s3 = st + x; int k3 = press(s3) - st.length(); if(k3 == 0) st = st + y; else st = st + x; } } } return st; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |     while(st.length() < N) {
      |           ~~~~~~~~~~~~^~~
combo.cpp:39:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |         if(st.length() != N - 1) {
      |            ~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...