이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "combo.h"
#define ll long long
#define ull unsigned ll
#define pb push_back
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define read_file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
using namespace std;
string chars[] = {"A", "B", "X", "Y"};
string guess_sequence(int N){
string out;
int no;
for (int i = 0; i < 3; i++){
int num = press(chars[i]);
if (num == 1){
out.append(chars[i]);
no = i;
break;
}
}
if (out.size() == 0) {
out.append(chars[3]);
no = 3;
}
for (int i = 1; i < N; i++){
cout << i << endl;
if (no == 3){
for (int j = 0; j < 2; j++){
int num = press(out+chars[j]);
if (num == i+1){
out.append(chars[j]);
break;
}
}
if (out.size() == i) out.append(chars[2]);
}
else{
for (int j = 0; j < 3; j++){
if (j == no) continue;
int num = press(out+chars[j]);
if (num == i+1){
out.append(chars[j]);
break;
}
}
if (out.size() == i) out.append(chars[3]);
}
}
return out;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:41:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
41 | if (out.size() == i) out.append(chars[2]);
| ~~~~~~~~~~~^~~~
combo.cpp:52:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
52 | if (out.size() == i) out.append(chars[3]);
| ~~~~~~~~~~~^~~~
combo.cpp:45:17: warning: 'no' may be used uninitialized in this function [-Wmaybe-uninitialized]
45 | if (j == no) continue;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |