이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
DEATH-MATCH
Davit-Marg
*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <iterator>
#include <ctype.h>
#include "combo.h"
#define mod 1000000007
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
using namespace std;
//
//int press(string p)
//{
// int ans;
// cout << p << endl;
// cin >> ans;
// return ans;
//}
string guess_sequence(int N)
{
string s[4] = {"A","B","X","Y"},ans,query;
if (press("AB")>=1)
{
if (press("A") == 1)
ans = "A";
else
{
ans = "B";
swap(s[0],s[1]);
}
}
else
{
if (press("X") == 1)
{
ans = "X";
swap(s[0], s[2]);
}
else
{
ans = "Y";
swap(s[0], s[3]);
}
}
while (ans.length() < N - 1)
{
query = ans + s[1];
for (int i = 1; i < 4; i++)
query += ans + s[2] + s[i];
int p = press(query);
if (p == ans.length() + 2)
ans += s[2];
else if(p==ans.length()+1)
ans += s[1];
else
ans += s[3];
}
while (ans.length() < N)
{
if (press(ans + s[1] + ans + s[2]) == ans.length() + 1)
{
if (press(ans + s[1]) == ans.length() + 1)
ans += s[1];
else
ans += s[2];
}
else
{
ans += s[3];
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:62:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
62 | while (ans.length() < N - 1)
| ~~~~~~~~~~~~~^~~~~~~
combo.cpp:70:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
70 | if (p == ans.length() + 2)
| ~~^~~~~~~~~~~~~~~~~~~
combo.cpp:72:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | else if(p==ans.length()+1)
| ~^~~~~~~~~~~~~~~~
combo.cpp:80:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
80 | while (ans.length() < N)
| ~~~~~~~~~~~~~^~~
combo.cpp:82:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
82 | if (press(ans + s[1] + ans + s[2]) == ans.length() + 1)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:84:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
84 | if (press(ans + s[1]) == ans.length() + 1)
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |