제출 #428806

#제출 시각아이디문제언어결과실행 시간메모리
428806Enkognit콤보 (IOI18_combo)C++14
5 / 100
1 ms328 KiB
    #include <bits/stdc++.h>
    #include <vector>
    #include "combo.h"
    #define ll long long
    #define mp make_pair
    #define pb push_back
    #define pii pair<int,int>
    #define pll pair<ll,ll>
    #define fi first
    #define se second

    using namespace std;

    string guess_sequence(int n) {
        vector<char> z={'A', 'B', 'X', 'Y'};
        string d;
        for (int i = 0; i < 2; i++) d+=z[i];
        string ans;
        ll p=press(d);
        if (p)
        {
            p=press("A");
            if (p)
            {
                ans+="A";
                z.erase(z.begin());
            }else
            {
                ans+="B";
                z.erase(z.begin()+1);
            }
        }else
        {
            p=press("X");
            if (p)
            {
                ans+="X";
                z.erase(z.begin()+2);
            }else
            {
                ans+="Y";
                z.erase(z.begin()+3);
            }
        }
        //cout << n << "\n";
        char lst='-';
        while (ans.size()<n-1)
        {
            //cout << ans << "\n";
            string d="";
            d+=ans;
            d+=z[0];
            d+=ans;
            d+=z[1];
            d+=z[0];
            d+=ans;
            d+=z[1];
            d+=z[1];
            d+=ans;
            d+=z[1];
            d+=z[2];
            assert(d.size()<=4*n);
            //cout << " " << d << "\n";
            ll p=press(d);
            if (p==ans.size())
                ans+=z[2];else
            if (p==ans.size()+1)
                ans+=z[0];else
                ans+=z[1];
        }
        bool ttt=0;
        for (int j = 0; j < z.size()-1; j++)
        {
            string d=ans;
            d+=z[j];
            ll p=press(d);
            if (p==ans.size()+1)
            {
                ans+=z[j];
                ttt=1;
                break;
            }
        }
        if (!ttt) ans+=z.back();
        //cout << ans << "\n";
        return ans;
    }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         while (ans.size()<n-1)
      |                ~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:1:
combo.cpp:62:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |             assert(d.size()<=4*n);
      |                    ~~~~~~~~^~~~~
combo.cpp:65:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |             if (p==ans.size())
      |                 ~^~~~~~~~~~~~
combo.cpp:67:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if (p==ans.size()+1)
      |                 ~^~~~~~~~~~~~~~
combo.cpp:72:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |         for (int j = 0; j < z.size()-1; j++)
      |                         ~~^~~~~~~~~~~~
combo.cpp:77:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |             if (p==ans.size()+1)
      |                 ~^~~~~~~~~~~~~~
combo.cpp:46:14: warning: unused variable 'lst' [-Wunused-variable]
   46 |         char lst='-';
      |              ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...