Submission #1072523

#TimeUsernameProblemLanguageResultExecution timeMemory
1072523RigobertusCombo (IOI18_combo)C++17
30 / 100
38 ms848 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; /*int press(string p) { cout << p << endl; int res; cin >> res; return res; }*/ string guess_sequence(int n) { string c[4] = {"A", "B", "X", "Y"}; string s = ""; int j; for (int i = 0; i < 4; i++) { if (i == 3 || press(c[i])) { s = c[i]; j = i; break; } } vector<int> a; for (int i = 0; i < 4; i++) { if (i != j) { a.push_back(i); } } set<int> vis; for (int i = 0; i < 3; i++) { vis.insert(i); } while (s.size() < n) { int k; int last = *vis.rbegin(); for (int i = 0; i < 3; i++) { k = i; if (!vis.count(i)) { vis.insert(i); continue; } if (i == last) { s += c[a[i]]; break; } string p = s + c[a[i]] + c[a[i]]; int x = press(p); if (x == p.size()) { s = p; break; } else if (x == p.size() - 1) { s += c[a[i]]; vis.erase(i); break; } } for (int i = k + 1; i < 3; i++) { vis.insert(i); } } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:39:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |     while (s.size() < n) {
      |            ~~~~~~~~~^~~
combo.cpp:54:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             if (x == p.size()) {
      |                 ~~^~~~~~~~~~~
combo.cpp:58:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |             else if (x == p.size() - 1) {
      |                      ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...