이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n)
{
string ans,v;
if (press("AB"))
{
if (press("A"))
ans="A",v="BXY";
else
ans="B",v="AXY";
}
else
{
if (press("X"))
ans="X",v="ABY";
else
ans="Y",v="ABX";
}
if (n==1)
return ans;
for (int i=2;i<n;i++)
{
string f;
f+=ans+v[0]+v[0]; //ABB , AXBB
f+=ans+v[0]+v[1]; //ABBABX , AXBBAXBX
f+=ans+v[0]+v[2]; //ABBABXABY , AXBBAXBXAXBY
f+=ans+v[1]; //ABBABXABYAX , AXBBAXBXAXBYAXX
int k=press(f);
if (k==ans.size()+2) //mora da zapocnue so ABB,ABX ili ABY / AXBB,AXBX ili AXBY
ans+=v[0];
else if (k==ans.size()+1) //mora da zapocnue so AX / AXX
ans+=v[1];
else //zapocnue samo so A / AX
ans+=v[2];
}
if (press(ans+v[0])==ans.size()+1)
ans+=v[0];
else if (press(ans+v[1])==ans.size()+1)
ans+=v[1];
else
ans+=v[2];
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if (k==ans.size()+2) //mora da zapocnue so ABB,ABX ili ABY / AXBB,AXBX ili AXBY
| ~^~~~~~~~~~~~~~
combo.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
34 | else if (k==ans.size()+1) //mora da zapocnue so AX / AXX
| ~^~~~~~~~~~~~~~
combo.cpp:39:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if (press(ans+v[0])==ans.size()+1)
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:41:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | else if (press(ans+v[1])==ans.size()+1)
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |