Submission #132475

#TimeUsernameProblemLanguageResultExecution timeMemory
132475nxteruCombo (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string ans; char c[3],d[4]={'A','B','X','Y'}; bool u[4]; string q; string guess_sequence(int n){ q+=d[0]; q+=d[1]; if(press(q)==1){ q.pop_back(); if(press(q)==1)u[0]=true; else u[1]=true; }else{ q.clear(); q.push_back(d[2]); if(press(q)==1)u[2]=true; else u[3]=true; } int k=0; for(int i=0;i<4;i++){ if(!u[i])c[k++]=d[i]; else ans.push_back(d[i]); } for(int i=2;i+1<=n;i++){ q.clear(); q+=ans; q.push_back(c[0]); for(int j=0;j<3;j++){ q+=ans; q.push_back(c[1]); q.push_back(c[j]); } int s=press(q); if(s==i-1)ans.push_back(c[2]); else if(s==i)ans.push_back(c[0]); else ans.push_back(c[1]); } if(ans.size()==n){ ans.push_back('/0'); return ans; } q.clear(); q+=ans; q.push_back(c[0]); q+=ans; q.push_back(c[1]); if(press(q)==n){ q.clear(); q+=ans; q.push_back(c[0]); if(press(q)==n)ans.push_back(c[0]); else ans.push_back(c[1]); }else ans.push_back(c[2]); ans.push_back('/0'); return ans; }

Compilation message (stderr)

combo.cpp:41:19: warning: multi-character character constant [-Wmultichar]
   41 |     ans.push_back('/0');
      |                   ^~~~
combo.cpp:56:17: warning: multi-character character constant [-Wmultichar]
   56 |   ans.push_back('/0');
      |                 ^~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:40:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   40 |   if(ans.size()==n){
      |      ~~~~~~~~~~^~~
combo.cpp:41:19: warning: overflow in conversion from 'int' to 'char' changes value from '12080' to ''0'' [-Woverflow]
   41 |     ans.push_back('/0');
      |                   ^~~~
combo.cpp:56:17: warning: overflow in conversion from 'int' to 'char' changes value from '12080' to ''0'' [-Woverflow]
   56 |   ans.push_back('/0');
      |                 ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...