Submission #466802

#TimeUsernameProblemLanguageResultExecution timeMemory
466802jazzupCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include<iostream> #include<cstring> int press(std::string s){ int r; std::cout<<s<<"\n"; std::cin>>r; return r; } std::string guess_sequence(int N){ std::string p = ""; p="AB"; char a[3]; int m = press(p); int c; else if(m==1){ c=press("A"); if(c==1){ a[0]='B'; a[1]='X'; a[2]='Y'; p="A"; } else{ a[0]='A'; a[1]='X'; a[2]='Y'; p="B"; } } else if(m==0){ c=press("X"); if(c==1){ a[0]='A'; a[1]='B'; a[2]='Y'; p="X"; } else{ a[0]='A'; a[1]='B'; a[2]='X'; p="Y"; } } std::string S; int x=p.length(); for(int i=x;i<N-1;i++){ S=p; S+=a[0]; S+=a[0]; S+=p; S+=a[0]; S+=a[1]; S+=p; S+=a[0]; S+=a[2]; S+=p; S+=a[1]; c=press(S); if(c==p.length()){ p+=a[2]; } else if(c==p.length()+1){ p+=a[1]; } else{ p+=a[0]; } } S=p; S+=a[0]; c=press(S); if(c==p.length()+1) return S; else{ S=p; S+=a[1]; c=press(S); if(c==p.length()+1) return S; else{ p+=a[2]; return p; } } } int main(){ int n; scanf("%d",&n); std::string s=guess_sequence(n); std::cout<<"ANS: "<<s; return 0; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:19:2: error: 'else' without a previous 'if'
   19 |  else if(m==1){
      |  ^~~~
combo.cpp:69:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |   if(c==p.length()){
      |      ~^~~~~~~~~~~~
combo.cpp:72:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |   else if(c==p.length()+1){
      |           ~^~~~~~~~~~~~~~
combo.cpp:86:6: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   86 |  if(c==p.length()+1)
      |     ~^~~~~~~~~~~~~~
combo.cpp:94:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   94 |   if(c==p.length()+1)
      |      ~^~~~~~~~~~~~~~
combo.cpp: In function 'int main()':
combo.cpp:105:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~