Submission #477040

#TimeUsernameProblemLanguageResultExecution timeMemory
477040glomeCombo (IOI18_combo)C++17
30 / 100
58 ms564 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { set<int> s; s.insert('A'); s.insert('B'); s.insert('X'); string S; char cur; for (int i = 0; i<N; i++) { if(i == 0) { bool ok = 0; for (char c : s) { if(press(string(1, c))) { S.push_back(c); s.erase(c); ok = 1; break; } } if(!ok) { S.push_back('Y'); s.erase('A'); cur = 'A'; } else { cur = 'Y'; } continue; } if(i == N - 1) { bool ok = 0; for (char c : s) { if(press(S + c) == S.size() + 1) { ok = 1; S.push_back(c); break; } } if(!ok) { S.push_back(cur); } continue; } bool ok1 = 0; bool ok2 = 0; string temp; for (char u : s) { temp.push_back(u); } char now1 = temp[0]; char now2 = temp[0]; int inow1 = 0; int inow2 = 0; while(true) { int k = press(S + now1 + now2); if(k == S.size() + 2) { break; } if(k == S.size() + 1) { ok1 = 1; if(inow2 == temp.size() - 1) { now2 = cur; break; } inow2++; now2 = temp[inow2]; continue; } if(inow1 == temp.size() - 1) { now1 = cur; continue; } inow1++; now1 = temp[inow1]; } S.push_back(now1); S.push_back(now2); i++; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if(press(S + c) == S.size() + 1) {
      |            ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:61:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |       if(k == S.size() + 2) {
      |          ~~^~~~~~~~~~~~~~~
combo.cpp:64:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |       if(k == S.size() + 1) {
      |          ~~^~~~~~~~~~~~~~~
combo.cpp:66:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         if(inow2 == temp.size() - 1) {
      |            ~~~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:74:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   74 |       if(inow1 == temp.size() - 1) {
      |          ~~~~~~^~~~~~~~~~~~~~~~~~
combo.cpp:49:10: warning: variable 'ok1' set but not used [-Wunused-but-set-variable]
   49 |     bool ok1 = 0;
      |          ^~~
combo.cpp:50:10: warning: unused variable 'ok2' [-Wunused-variable]
   50 |     bool ok2 = 0;
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...