Submission #677094

#TimeUsernameProblemLanguageResultExecution timeMemory
677094ToxtaqCombo (IOI18_combo)C++17
30 / 100
52 ms308 KiB
#include<bits/stdc++.h> using namespace std; //string S; //int num_moves = 0; //constexpr int MAX_N = 2000; //constexpr int MAX_NUM_MOVES = 8000; // //void wrong_answer(const char *MSG) { // printf("Wrong Answer: %s\n", MSG); // exit(0); //} //int N; // //int cnt = 0; //int press(std::string p) { // cnt++; // if (++num_moves > MAX_NUM_MOVES) { // wrong_answer("too many moves"); // } // int len = p.length(); // if (len > 4 * N) { // wrong_answer("invalid press"); // } // for (int i = 0; i < len; ++i) { // if (p[i] != 'A' && p[i] != 'B' && p[i] != 'X' && p[i] != 'Y') { // wrong_answer("invalid press"); // } // } // int coins = 0; // for (int i = 0, j = 0; i < len; ++i) { // if (j < N && S[j] == p[i]) { // ++j; // } else if (S[0] == p[i]) { // j = 1; // } else { // j = 0; // } // coins = std::max(coins, j); // } // return coins; //} int press(string s); string guess_sequence(int N){ string s; char fchar; if(press("A") == 1)fchar = 'A'; else if(press("B") == 1)fchar = 'B'; else if(press("X") == 1)fchar = 'X'; else fchar = 'Y'; s += fchar; while(s.length() < N){ int len = s.length(); if(fchar != 'A'){ for(int j = 0;j < N - len;++j)s += 'A'; int coins = press(s); while(s.length() > coins)s.pop_back(); // cout << 'A' << " " << s.length() << '\n'; } if(fchar != 'B'){ for(int j = 0;j < N - len;++j)s += 'B'; int coins = press(s); while(s.length() > coins)s.pop_back(); // cout << 'B' << " " << s.length() << '\n'; } if(fchar != 'X'){ for(int j = 0;j < N - len;++j)s += 'X'; int coins = press(s); while(s.length() > coins)s.pop_back(); // cout << 'X' << " " << s.length() << '\n'; } if(fchar != 'Y'){ for(int j = 0;j < N - len;++j)s += 'Y'; int coins = press(s); while(s.length() > coins)s.pop_back(); // cout << 'Y' << " " << s.length() << '\n'; } } return s; } //int main() //{ // S = "X"; // for(int i = 0;i < 1999;++i)S += 'Y'; // N = S.length(); // cout << guess_sequence(S.length()); // cout << endl << S.length() << " " << num_moves; //}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:51:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |     while(s.length() < N){
      |           ~~~~~~~~~~~^~~
combo.cpp:56:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |             while(s.length() > coins)s.pop_back();
      |                   ~~~~~~~~~~~^~~~~~~
combo.cpp:62:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |             while(s.length() > coins)s.pop_back();
      |                   ~~~~~~~~~~~^~~~~~~
combo.cpp:68:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   68 |             while(s.length() > coins)s.pop_back();
      |                   ~~~~~~~~~~~^~~~~~~
combo.cpp:74:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   74 |             while(s.length() > coins)s.pop_back();
      |                   ~~~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...