이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define ROF(i,a,b) for(int i=(a); i>=(b); --i)
#define pb push_back
#define eb emplace_back
#define SZ(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define make_unique(a) sort(all((a))), (a).erase(unique(all((a))),(a).end())
#define x first
#define y second
#define MP make_pair
#define MT make_tuple
#define debug(x) cout << #x << " = " << x << endl
#define debug2(x,y) FOR(i,1,y) cout << "##"; cout << #x << " = " << x << endl
#define mset(x) memset((x), 0, sizeof(x))
using namespace std;
typedef long long i64;
typedef tuple<int,int,int> iii;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;
int readInt(){ int a; scanf("%d",&a); return a; }
i64 readLong(){ i64 a; scanf("%lld",&a); return a;}
void readString(char *s){ scanf(" %s",s); }
char A[]={'A','B','X','Y'};
string guess_sequence(int N) {
string p = "";
int res;
// binary search
if(press("AB") >= 1){
if(press("B")) swap(A[0],A[1]);
}else{
if(press("X")) swap(A[0],A[2]);
else swap(A[0],A[3]);
}
p = A[0];
// guess until N-1
FOR(i, 2, N-1){
string g = "";
FOR(j,1,3) g+=p+A[1]+A[j];
g+=p+A[2];
int ans = press(g);
if(ans == i+1) p += A[1];
else if(ans == i) p += A[2];
else p += A[3];
}
FOR(i, 1, 2){
if(press(p+A[i])==N){
p += A[i];
break;
}
}
if(p.size() != N) p+=A[3];
return p;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:59:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
59 | if(p.size() != N) p+=A[3];
| ~~~~~~~~~^~~~
combo.cpp:34:6: warning: unused variable 'res' [-Wunused-variable]
34 | int res;
| ^~~
combo.cpp: In function 'int readInt()':
combo.cpp:26:28: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | int readInt(){ int a; scanf("%d",&a); return a; }
| ~~~~~^~~~~~~~~
combo.cpp: In function 'i64 readLong()':
combo.cpp:27:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
27 | i64 readLong(){ i64 a; scanf("%lld",&a); return a;}
| ~~~~~^~~~~~~~~~~
combo.cpp: In function 'void readString(char*)':
combo.cpp:28:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
28 | void readString(char *s){ scanf(" %s",s); }
| ~~~~~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |