이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define pll pair<ll,ll>
#define ff first
#define ss second
//#define endl "\n"
#define pb push_back
#define F(i,a,b) for(ll i=a;i<=b;i++)
const ll maxn=4e6+3000;
const ll base=2e9;
const ll mod= 1e9+7 ;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
/*ll press(string t)
{
cout <<t<<endl;
ll x;
cin>> x;
return x;
}*/
string guess_sequence(ll n)
{
ll p=press("AB");
set<char> st;
st.clear();
st.insert('A');
st.insert('B');
st.insert('X');
st.insert('Y');
string res;
res.clear();
if (p)
{
ll p=press("A");
if (p)
st.erase('A'),res.pb('A');
else
st.erase('B'),res.pb('B');
}
else
{
ll p=press("X");
if (p)
st.erase('X'),res.pb('X');
else
st.erase('Y'),res.pb('Y');
}
if (n==1) return res;
for (int i=2; i<=n-1; i++)
{
string pt;
pt.clear();
for (auto to:st)
{
pt+=res;
pt.pb(*st.begin());
pt.pb(to);
}
ll cnt=0;
for (auto to:st)
{
cnt++;
if (cnt==2)
{
pt+=res;
pt.pb(to);
break;
}
}
ll p=press(pt);
ll h=0;
if (p==res.length()+2)
{
h=1;
}
else if (p==res.length()+1)
{
h=2;
}
else
{
h=3;
}
cnt=0;
for (auto to:st)
{
cnt++;
if (cnt==h)
{
res.pb(to);
break;
}
}
}
ll cnt=0;
for (auto to:st)
{
cnt++;
if (cnt==3) break;
string pt=res;
pt.pb(to);
if (press(pt)==n)
{
res=pt;
break;
}
}
if (res.length()!=n)
{
auto it=st.end();
it--;
res.pb(*it);
}
return res;
}
/*int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if (fopen("t.inp","r"))
{
freopen("test.inp","r",stdin);
freopen("test.out","w",stdout);
}
cout <<guess_sequence(7);
}*/
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:78:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
78 | if (p==res.length()+2)
| ~^~~~~~~~~~~~~~~~
combo.cpp:82:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | else if (p==res.length()+1)
| ~^~~~~~~~~~~~~~~~
combo.cpp:115:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
115 | if (res.length()!=n)
| ~~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |