Submission #677528

#TimeUsernameProblemLanguageResultExecution timeMemory
677528hello_there_123Combo (IOI18_combo)C++17
0 / 100
1 ms208 KiB
#include<bits/stdc++.h> //#include "combo.h" using namespace std; string arr[4]={"A","B","X","Y"}; vector<string>v; int press(string s); string guess_sequence(int N){ if(N==1){ for(int i=0;i<4;i++){ if(press(arr[i]) == 1) return arr[i]; } } else{ string ans = ""; string start = ""; for(int i=0;i<4;i++){ string tr = ""; for(int j=0;j<4;j++){ tr = tr+arr[i] + arr[j]; } int x = press(tr); if(x==2){ start = arr[i]; break; } } ans = start; assert(ans.length() == 1); for(int i=0;i<4;i++) if(arr[i]!=start) v.push_back(arr[i]); for(int i=0;i<N-2;i++){ string tr = ""; tr += ans + arr[0]; tr += ans + arr[1] + arr[0]; tr += ans + arr[1] + arr[1]; tr += ans + arr[1] + arr[2]; int x = press(tr); if(x == ans.length()) ans+=arr[2]; else if(x == ans.length() +1) ans += arr[0]; else ans += arr[1]; } if(press(ans+arr[0]) == N) return ans+arr[0]; if(press(ans+arr[1]) == N) return ans+arr[1]; return ans+arr[2]; } return ""; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |    if(x == ans.length()) ans+=arr[2];
      |       ~~^~~~~~~~~~~~~~~
combo.cpp:38:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |    else if(x == ans.length() +1) ans += arr[0];
      |            ~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...