Submission #1066738

#TimeUsernameProblemLanguageResultExecution timeMemory
1066738Muhammad_AneeqCombo (IOI18_combo)C++17
100 / 100
45 ms11912 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; char d[4]={'A','B','X','Y'}; map<string,int>vis; int ask(string x) { if (vis.find(x)==vis.end()) vis[x]=press(x); return vis[x]; } string guess_sequence(int N) { srand(time(0)); string init=""; string g="AB",y="AX"; if (ask(g)&&ask(y)) init+='A'; if (ask(g)&&!ask(y)) init+='B'; if (!ask(g)&&ask(y)) init+='X'; if (!ask(g)&&!ask(y)) init+='Y'; vector<int>c; for (int i=0;i<4;i++) { if (init[0]==d[i]) continue; c.push_back(d[i]); } for (int i=1;i<N;i++) { if (i!=N-1) { string z; z+=init; z+=c[0]; string g; g+=init; g+=c[1]; for (int j=0;j<3;j++) z+=g,z+=c[j]; int sz=ask(z); if (sz==i) init+=c[2]; if (sz==i+1) init+=c[0]; if (sz==i+2) init+=c[1]; } else { for (int j=0;j<2;j++) { init+=c[j]; if (ask(init)==i+1) break; init.pop_back(); } if (init.size()==i) init+=c[2]; } } return init; }

Compilation message (stderr)

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