제출 #206540

#제출 시각아이디문제언어결과실행 시간메모리
206540vardan__02콤보 (IOI18_combo)C++14
0 / 100
1283 ms2228 KiB
#include <algorithm>
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <set>
#include <map>
#include "combo.h"
using namespace std;
string guess_sequence(int N)
{
    int n = N;
    string ans = "";
    string ban = "";
    int x;
    x = press("AB");
    if(x == 0)
    {
        x = press("X");
        if(x == 0)
        {
            ans = "Y";
            ban = "ABX";
        }
        else
        {
            ans = "X";
            ban = "ABY";
        }
    }
    else
    {
        x = press("A");
        if(x == 0)
        {
            ans = "B";
            ban = "XYA";
        }
        else
        {
            ans = "A";
            ban = "XYB";
        }
    }
    if(n == 1)
        return ans;
    while(ans.size() <= n - 2)
    {
        string s = ans + ban[0] + ban[2] + ans + ban[0] + ban[0] + ans + ban[0] + ban[1] + ans + ban[1];
        x = press(s);
        if(x == ans.size())
            ans = ans + ban[2];
        else
        {
            if(x == ans.size() + 1)
                ans = ans + ban[1];
            else
                ans = ans + ban[0];
        }
    }
    string s = ans + ban[0];
    x = press(s);
    if(x == ans.size() + 1)
        ans = ans + ban[0];
    else
    {
        s = ans + ban[1];
        x = press(s);
        if(x == ans.size() + 1)
            ans = ans + ban[1];
        else
            ans = ans + ban[2];
    }
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:53:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |     while(ans.size() <= n - 2)
      |           ~~~~~~~~~~~^~~~~~~~
combo.cpp:57:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |         if(x == ans.size())
      |            ~~^~~~~~~~~~~~~
combo.cpp:61:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             if(x == ans.size() + 1)
      |                ~~^~~~~~~~~~~~~~~~~
combo.cpp:69:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     if(x == ans.size() + 1)
      |        ~~^~~~~~~~~~~~~~~~~
combo.cpp:75:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |         if(x == ans.size() + 1)
      |            ~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...