제출 #526664

#제출 시각아이디문제언어결과실행 시간메모리
526664lcs147콤보 (IOI18_combo)C++17
10 / 100
68 ms464 KiB
#include<bits/stdc++.h>
#include"combo.h"
using namespace std;

// string s;
// int cnt = 0;
// int press(string p) {
//     int res = 0;
//     for(int i=0; i<p.size(); i++) {
//         for(int t=1; t<=s.size() && i+t<=p.size(); t++) {
//             if(s.substr(0, t) == p.substr(i, t)) {
//                 res = max(res, t);
//             }
//         }
//     }
//     cnt++;
//     return res;
// }

string guess_sequence(int n) {
    set<char> possible = {'A','B','X','Y'};

    string res;
    while(res.size() < n) {
        for(char c:possible) {
            if(press(res+c) == res.size()+1) {
                res += c;
                if(res.size() == 1) {
                    possible.erase(c);
                }
                break;
            }
        }
    }
    return res;
}

// int32_t main(){
//     ios_base::sync_with_stdio(false);
//     cin.tie(0);
//     #define endl '\n'

//     s = "X";
//     vector<char> possible = {'A','B','Y'};
//     while(s.size() < 100) s += possible[rand()%3];
//     cout << s << endl;
    
//     cout << guess_sequence(s.size()) << endl;
//     cout << cnt << endl;

//     return 0;
// }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     while(res.size() < n) {
      |           ~~~~~~~~~~~^~~
combo.cpp:26:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |             if(press(res+c) == res.size()+1) {
      |                ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...