Submission #913841

#TimeUsernameProblemLanguageResultExecution timeMemory
913841stefanneaguCombo (IOI18_combo)C++17
100 / 100
14 ms1972 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { // primul char set<string> s; s.insert("A"); s.insert("B"); s.insert("X"); s.insert("Y"); string primul = ""; if(n == 1) { for(auto it : s) { if(it == "Y") { primul = it; break; } if(press(it) == 1) { primul = it; break; } } return primul; } if(press("AB") != 0) { if(press("A") == 1) { primul = "A"; } else { primul = "B"; } } else { if(press("X") == 1) { primul = "X"; } else { primul = "Y"; } } s.erase(primul); // primul e primul char string ans = primul; string add = ""; vector<string> v; for(auto it : s) { v.push_back(it); } for(int i = 2; i < n; i ++) { string apel = ans; apel += v[0]; apel += ans; apel += v[1]; apel += v[2]; apel += ans; apel += v[1]; apel += v[1]; apel += ans; apel += v[1]; apel += v[0]; int x = press(apel); if(x == i - 1) { ans += v[2]; } else if(x == i) { ans += v[0]; } else if(x == i + 1) { ans += v[1]; } else { assert("ce se" == "intampla"); } } for(auto it : v) { string apel = ans; apel += it; if(it == v[2]) { return apel; } if(press(apel) == n) { return apel; } } }

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:67:22: warning: comparison with string literal results in unspecified behavior [-Waddress]
   67 |       assert("ce se" == "intampla");
      |              ~~~~~~~~^~~~~~~~~~~~~
combo.cpp:7:15: warning: control reaches end of non-void function [-Wreturn-type]
    7 |   set<string> s;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...