이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//記得跳題
// #pragma GCC optimize("O3,unroll_loops")
// #pragma GCC target("avx2")
#include<iostream>
#include<array>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<iomanip>
#include<bitset>
#include<tuple>
#include<random>
using namespace std;
#define ll long long
#define DB double
#define LL __int128_t
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>=b;i--)
#define INF (ll)(2e9)
#define F first
#define S second
#define X first
#define Y second
#define eps (DB)(1e-10)
#define pb push_back
#define mp make_pair
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#include "combo.h"
/*string ans;
int press(string p) {
REP(i, (int)ans.size(), 1) {
string tmp = ans.substr(0, i);
if (p.find(tmp) != p.npos) return i;
}
return 0;
}
*/
char c[4] = {'A', 'B', 'X', 'Y'}, cc[3];
string guess_sequence(int n) {
string out;
int p;
int cnt = 0;
if (n == 1) {
FOR(j, 0, 4) {
cnt++;
out += c[j];
if (cnt == 4) break;
p = press(out);
if (p) break;
out.clear();
}
return out;
}
string s = "AB";
p = press(s);
if (p) {
s = "A";
p = press(s);
if (p == 1) {
out = "A";
} else {
out = "B";
}
} else {
s = "X";
p = press(s);
if (p == 1) {
out = "X";
} else {
out = "Y";
}
}
// cout << "out = " << out << endl;
cnt = 0;
FOR(j, 0, 4) if (c[j] != out[0]) cc[cnt++] = c[j];
FOR(i, 1, n) {
if (i == n - 1) {
cnt = 0;
string tmp;
FOR(j, 0, 3) {
tmp = out + cc[j];
if (j == 2) break;
p = press(tmp);
if (p == n) break;
}
out = tmp;
break;
}
string tmp = out + cc[0] + cc[0] + out + cc[0] + cc[1] + out + cc[0] + cc[2] + out + cc[1];
p = press(tmp);
// cout << "tmp = " << tmp << " p = " << p << endl;
if (p == out.size()) out += cc[2];
else if (p == out.size() + 1) out += cc[1];
else out += cc[0];
}
return out;
}
/*
signed main() {
AC;
// go
int t; cin >> t;
while (t--) {
string n; cin >> n;
ans = n;
cout << guess_sequence((int)n.size()) << endl;
}
}*/
/*
????????????????????????????????????????????????
*/
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:116:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
116 | if (p == out.size()) out += cc[2];
| ~~^~~~~~~~~~~~~
combo.cpp:117:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
117 | else if (p == out.size() + 1) out += cc[1];
| ~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |