Submission #503695

#TimeUsernameProblemLanguageResultExecution timeMemory
503695cristi_aCombo (IOI18_combo)C++17
0 / 100
1 ms328 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { char lets[4]; strcpy(lets,"ABXY"); string rez = ""; if(press("AB")) rez = press("A") ? "A" : "B"; else rez = press("X") ? "X" : "Y"; for(int i=0; i<4; i++) if(lets[i]==rez[0]) { strcpy(lets+i,lets+i+1); break; } for(int i=1; i<N; i++) { if(i==N-1) { if(press(rez+lets[0])==N) return (rez+lets[0]); else if(press(rez+lets[1])==N) return (rez+lets[1]); else return (rez+lets[2]); } else { string temp = rez + lets[1] + rez + lets[0] + lets[0] + rez + lets[0] + lets[1] + rez + lets[0] + lets[2]; int w = press(temp); if(w == i+1) rez = rez + lets[1]; else if(w==i+2) rez = rez + lets[0]; else rez = rez + lets[2]; } } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:18: warning: control reaches end of non-void function [-Wreturn-type]
    8 |     string rez = "";
      |                  ^~
In file included from /usr/include/string.h:495,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from combo.cpp:1:
In function 'char* strcpy(char*, const char*)',
    inlined from 'std::string guess_sequence(int)' at combo.cpp:7:11:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:90:33: warning: 'char* __builtin___strcpy_chk(char*, const char*, long unsigned int)' writing 5 bytes into a region of size 4 [-Wstringop-overflow=]
   90 |   return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:10: note: at offset 0 to object 'lets' with size 4 declared here
    6 |     char lets[4];
      |          ^~~~
In file included from /usr/include/string.h:495,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from combo.cpp:1:
In function 'char* strcpy(char*, const char*)',
    inlined from 'std::string guess_sequence(int)' at combo.cpp:7:11:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:90:33: warning: 'void* __builtin___memcpy_chk(void*, const void*, long unsigned int, long unsigned int)' forming offset 4 is out of the bounds [0, 4] of object 'lets' with type 'char [4]' [-Warray-bounds]
   90 |   return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:10: note: 'lets' declared here
    6 |     char lets[4];
      |          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...