Submission #1022234

#TimeUsernameProblemLanguageResultExecution timeMemory
1022234khomeCombo (IOI18_combo)C++17
5 / 100
768 ms262144 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { vector<char> a; a={'A', 'B', 'X','Y'}; string res, cur; char per; int ab = press("AB"), bx = press("BX"), id; if (ab == 1) { if (bx == 1) {per = 'B'; id = 1; res += per;} if (bx == 2) {per = 'B'; id = 1; res += "BX";} if (bx == 0) {per = 'A'; id = 0; res += per;} } else if (ab == 0) { if (bx == 1) {per = 'X'; id = 2;} else {per = 'Y'; id = 3;} res += per; } else if (ab == 2) {per = 'A'; id = 0; res = "AB";} int n = res.size(); if (n==1){ if (press(res + a[(id+1)%4] + res + a[(id+2)%4]) == 2) { // id == 3 res = "Y"; press("YAYB") == 1; if (press(res + a[(id+1)%4]) == 2) {res += a[(id+1)%4];} else res += a[(id+2)%4]; } else { // press("YAYB") == 0; res += a[(id+3)%4]; } } n = res.size(); while (n!=N){ // int ij = -1; for (char i : a){ // ij++; n = res.size(); if (n == N) break; if (i != per && i!= res[-1]){ cur = res; // cout << "current = " << res << ' '; while (res.size()!=N) res+=i; // cout << "now = " << res << ' '; int r = press(res); // cout << "r = " << r << " n = " << n << ' '; if (r > n){ cur = ""; for (int j = 0; j < r; j++){ cur += res[j]; } // cout << "changed = " << cur; res = cur; // cout << "\n"; continue; } res = cur; // cout << "\n"; } } } return res; //XYABABYBA //XYAXYBBXYBYXYBA // int i = 0; // if (a[i] != per){ // i = 0 == > a[i] == "A"; // if (press(res+a[i]+res+a[(i+1)%4]) == 2){ // press("YAYB") == 1; // if (press(res+a[(i+2)%4]+res+a[(i+1)%4]) == 2) res += a[(i+1)%4]; // // press("YXYB") == 1; // else res += a[i]; //press("YXYB") == 0; // } // else res += a[(i+2)%4]; // } // cout << res << "\n"; // while (res.size()!=N){ // n = res.size(); // } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |           while (res.size()!=N) res+=i;
      |                  ~~~~~~~~~~^~~
combo.cpp:32:21: warning: 'id' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |         res += a[(id+3)%4];
      |                  ~~~^~~
combo.cpp:42:22: warning: 'per' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |         if (i != per && i!= res[-1]){
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...