Submission #76338

#TimeUsernameProblemLanguageResultExecution timeMemory
76338darthsidiousCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <string> //A B X Y using namespace std; int press(string p) { string secret = "ABXYXXYY"; int ans = 0; for(int i=0;i<secret.size();i++) { if(secret[i] == p[i]) ans++; else break; } return ans; } string guess_sequence(int N) { string chars = "ABXY"; string c[3]; int start_c = 0; for(int i=0;i<4;i++) { string tmp(1, chars[i]); int r = press(tmp); if(r == 1) { start_c = i; break; } } for(int i=0;i<3;i++) { if(start_c <= i) c[i] = string(1, chars[i+1]); else c[i] = string(1, chars[i]); } // cout << (string)c << endl; string ans(1, chars[start_c]); // cout << "Starting with " << ans << endl; int test_char = 0; for(int i=0;i<7996;i++) { string test = ans; int len = test.size(); test = ans + c[test_char%3]; // cout << "testing " << test << endl; test_char++; if(press(test) > len) { // cout << "Improved..." << endl; ans = test; } // cout << ans << endl; if(ans.size() == N) break; // if(i > N) // break; // while(true) { //construct test string // for(int j=0;j<3;j++) { // test += ans + c[j]; // } // } } return ans; } // int main() { // cout << guess_sequence(8) << endl; // }

Compilation message (stderr)

combo.cpp: In function 'int press(std::string)':
combo.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0;i<secret.size();i++) {
      |              ~^~~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:59:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   59 |   if(ans.size() == N)
      |      ~~~~~~~~~~~^~~~
/usr/bin/ld: /tmp/ccDYCnte.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccmCtL5g.o:combo.cpp:(.text+0x180): first defined here
collect2: error: ld returned 1 exit status