제출 #1014529

#제출 시각아이디문제언어결과실행 시간메모리
1014529nisanduu콤보 (IOI18_combo)C++14
10 / 100
32 ms1372 KiB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// int press(string s){
//     string s1 = "XBA";
//     for(ll i=0;i<s.length();i++){
//         if(s[i]==s1[0]){
//             ll cnt = 0;
//             for(ll j=i;j<min(s.length(),i+s1.length());)
//         }
//     }
// }
string guess_sequence(int n){
    string st = "";
    char ct = 'A';
    vector<char> cs = {'A','B','X','Y'};
    for(auto z:cs){
        char x = z;
        string tmp = "";;
        tmp += x;
        if(press(tmp)==1){
            st = tmp;
            ct = x;
            break;
        }
    }
    
    string ans = st;
    vector<char> other = {'A','B','X','Y'};
    auto ite = find(other.begin(),other.end(),ct);
    other.erase(ite);
    vector<string> possible;
    for(ll i=0;i<3;i++){
        string s2 = "";
        s2+=other[i];
        for(ll j=0;j<3;j++){
            if(i!=j){
                string tmp=s2;
                tmp += other[j];
                possible.push_back(tmp);
            }
        }
    }
    ll p = 1;
    for(ll i=1;i<n;i++){
        string s1 = "",s2 = "";
        s1 += (ans + other[0] + ans + other[1]);
        s2 += (ans + other[2]);
        int sc1 = press(s1);
        if(sc1 > ans.size()){
            s1 = (ans + other[0]);
            sc1 = press(s1);
            if(sc1 > ans.size()){
                ans += other[0];
            }else{
                ans += other[1];
            }
        }else{
            ans += other[2];
        }
    }
    
    // while(p+1 < n){
    //     string s1 = "",s2 = "";
    //     s1 += (ans + possible[0] + ans + possible[1] + ans + possible[2]);
    //     s2 += (ans + possible[3] + ans + possible[4] + ans + possible[5]);
    //     int sc1 = press(s1);
    //     if(sc1 > ans.size()+1){
    //         s1 = (ans + possible[0]+ ans + possible[1]);
    //         s2 = (ans + possible[2]);
    //         sc1 = press(s1);
    //         sc2 = press(s2);
    //         if(sc1 > sc2){
    //             s1 = (ans + possible[0]);
    //         }else{
    //             if(sc2 == ans.size()+1){
    //                 ans = ans + possible[2][0] + possible[2][0];
    //             }else{
    //                 ans = ans + possible[2];
    //             }
    //         }
    //     }else{
    //         s1 = (ans + possible[3]+ ans + possible[4]);
    //         s2 = (ans + possible[5]);
            
    //     }
    // }
    
    
    return ans;
}

// int main()
// {
//     cout<<guess_sequence(3);

//     return 0;
// }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:58:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         if(sc1 > ans.size()){
      |            ~~~~^~~~~~~~~~~~
combo.cpp:61:20: 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(sc1 > ans.size()){
      |                ~~~~^~~~~~~~~~~~
combo.cpp:52:8: warning: unused variable 'p' [-Wunused-variable]
   52 |     ll p = 1;
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...