Submission #569454

#TimeUsernameProblemLanguageResultExecution timeMemory
569454NemanjaSo2005Combo (IOI18_combo)C++14
100 / 100
51 ms636 KiB
#include "combo.h" #include<bits/stdc++.h> #define ll long long using namespace std; char ps,slovo[5]={' ','A','B','X','Y'}; string tmp,nasli; ll Ng,bp; int pritisni(string x){ bp++; if(bp>8000) exit(-1); if(x.size()>Ng*4) exit(-2); int len=x.size(); for (int i = 0; i < len; ++i) { if (x[i] != 'A' && x[i] != 'B' && x[i] != 'X' && x[i] != 'Y') { exit(-1); } } return press(x); } string guess_sequence(int N) { Ng=N; if(pritisni("AB")){ if(pritisni("A")) ps='A'; else ps='B'; } else{ if(pritisni("X")) ps='X'; else ps='Y'; } for(int i=1;i<=3;i++){ if(slovo[i]==ps){ for(int j=i;j<=3;j++) slovo[j]=slovo[j+1]; break; } } nasli.push_back(ps); if(N==1){ return nasli; } for(int i=2;i<N;i++){ tmp.clear(); tmp+=nasli; tmp.push_back(slovo[1]); tmp.push_back(slovo[1]); tmp+=nasli; tmp.push_back(slovo[1]); tmp.push_back(slovo[2]); tmp+=nasli; tmp.push_back(slovo[1]); tmp.push_back(slovo[3]); tmp+=nasli; tmp.push_back(slovo[2]); int vred=pritisni(tmp); if(vred==(int)nasli.size()+2) nasli.push_back(slovo[1]); else if(vred==(int)nasli.size()+1) nasli.push_back(slovo[2]); else nasli.push_back(slovo[3]); } tmp=nasli; tmp.push_back(slovo[1]); if(pritisni(tmp)==N) return tmp; tmp=nasli; tmp.push_back(slovo[2]); if(pritisni(tmp)==N) return tmp; nasli.push_back(slovo[3]); return nasli; }

Compilation message (stderr)

combo.cpp: In function 'int pritisni(std::string)':
combo.cpp:12:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   12 |    if(x.size()>Ng*4)
      |       ~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...