Submission #1071694

#TimeUsernameProblemLanguageResultExecution timeMemory
1071694RigobertusCombo (IOI18_combo)C++17
10 / 100
47 ms1100 KiB
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> #include <queue> #include <string> //#define int long long #include "combo.h" using namespace std; string guess_sequence(int n) { string c[4] = {"A", "B", "X", "Y"}; string s = ""; bool vis[4]; for (int i = 0; i < 4; i++) { vis[i] = 0; } int j; for (int i = 0; i < 4; i++) { if (press(c[i])) { s = c[i]; j = i; break; } } while (int(s.size()) < n) { for (int i = 0; i < 4; i++) { if (i == j || vis[i]) { vis[i] = 0; continue; } string p = s + c[i] + c[i]; if (press(p) == int(p.size())) { s = p; break; } else if (press(p) == int(p.size()) - 1) { s += c[i]; vis[i] = 1; break; } } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:13: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   29 |             if (i == j || vis[i]) {
      |             ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...