제출 #797000

#제출 시각아이디문제언어결과실행 시간메모리
797000polya콤보 (IOI18_combo)C++14
30 / 100
36 ms444 KiB
#include<bits/stdc++.h>
#include<combo.h>

using namespace std;

char d[4] = {'A', 'B', 'X', 'Y'};

string guess_sequence(int N) {
       string seq;
       int ans = 0, data;
       for (int i=0; i<3; i++) {
           string a; a.push_back(d[i]);
           ans = press(a);
           if (ans == 1) {
                   data = i;
                   seq.push_back(d[i]);
                   break;
           }
       }
       if (ans == 0) {
               seq.push_back(d[3]);
               for (int i=1; i<N; i++) {
                   string a = seq; a.push_back('A');
                   ans = press(a);
                   if (ans == a.size()) seq.push_back('A');
                   else {
                        string b = seq; b.push_back('B');
                        ans = press(b);
                        if (ans == b.size()) seq.push_back('B');
                        else seq.push_back('X');
                   }
               }
       }
       else {
            for (int i=1; i<N; i++) {
                for (int j=0; j<3; j++) {
                    if (j != data) {
                          string a = seq;
                          a.push_back(d[j]);
                          ans = press(a);
                          if (ans == a.size()) {
                             seq.push_back(d[j]);
                             break;
                          }
                    }
                }
                if (seq.size() != i+1) seq.push_back('Y');
            }
       }
       return seq;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:25:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |                    if (ans == a.size()) seq.push_back('A');
      |                        ~~~~^~~~~~~~~~~
combo.cpp:29:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |                         if (ans == b.size()) seq.push_back('B');
      |                             ~~~~^~~~~~~~~~~
combo.cpp:41:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |                           if (ans == a.size()) {
      |                               ~~~~^~~~~~~~~~~
combo.cpp:47:32: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |                 if (seq.size() != i+1) seq.push_back('Y');
      |                     ~~~~~~~~~~~^~~~~~
combo.cpp:37:21: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]
   37 |                     if (j != data) {
      |                     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...