Submission #583929

#TimeUsernameProblemLanguageResultExecution timeMemory
583929LIFCombo (IOI18_combo)C++14
0 / 100
1 ms208 KiB
#include "combo.h" #include<bits/stdc++.h> std::string guess_sequence(int N) { std::string p = ""; int n = N; char k[4] = {'A','B','X','Y'}; int first=999; for(int i=0;i<3;i++) { std:: string ss = p; ss = ss + k[i]; int kk = press(ss); if(kk == 1) { first = i; break; } } int check1,check2; if(first == 999 )//that means first haven't been changed { first = 3; } p = p + k[first]; for (int i = 1; i < n-1;i++) { std::string tt = p; std::string ss=""; int kk = 0; for(int j = 0;j < 3; j++) { tt = p; if(j == first)continue; if(kk == 0) { check1 = j; tt += k[j]; ss += tt; } else { check2 = j; tt += k[j]; std::string xxx= tt; for(int pk=0;pk<4;pk++) { if(pk==first)continue; tt = xxx + k[pk]; ss+= tt; } } kk++; } int ans= press(ss); if(ans == i+1) { p = p + k[check1]; } else { if(ans == i+2) { p = p+k[check2]; } else { for(int j=0;j<4;j++) { if(j!=check1&&j!=check2&&j!=first) { p = p + k[j]; } } } } } for(int j=0;j<3;j++) { std::string ss = p; if(j == first )continue; ss += k[j]; if(press(ss) == n) { p = p+k[j]; break; } } if(p.size()!=n) { p = p + k[3]; } return p; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:92:13: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   92 |  if(p.size()!=n)
      |     ~~~~~~~~^~~
combo.cpp:67:19: warning: 'check2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   67 |     p = p+k[check2];
      |           ~~~~~~~~^
combo.cpp:61:20: warning: 'check1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   61 |    p = p + k[check1];
      |            ~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...