제출 #534467

#제출 시각아이디문제언어결과실행 시간메모리
534467MrDeboo콤보 (IOI18_combo)C++17
0 / 100
1 ms200 KiB
#include "combo.h"
#include <bits/stdc++.h>
// #define int long long
using namespace std;
std::string guess_sequence(int n) {
    srand(time(NULL));
    char f[]={'A','B','X','Y'};
    string s;
    vector<char>ve;
    for(auto &i:f)ve.push_back(i);
    vector<char>v=ve;
    int cnt=0;
    while(s.size()!=n){
        bool bl=0;
        map<char,bool>mp;
        for(int w=0;w<v.size();w++){
            string G;
            G+=v[w];
            for(int i=0;i<min(50,4*n-((int)s.size())-1);i++){
                if(s.size()==0){
                    char a=ve[rand()%ve.size()];
                    while(a==G[0]){
                        a=ve[rand()%ve.size()];
                    }
                }
                else G+=ve[rand()%ve.size()];
            }
            int k=press(s+G);
            cnt++;
            if(k>s.size()){
                int F=s.size();
                if(k!=G.size()+F)mp[G[k-s.size()]]=1;
                for(int i=0;i<k-F;i++){
                    s+=G[i];
                }
                bl=1;
                break;
            }
        }
        if(!bl)s+=v.back();
        if(cnt==1){
            vector<char>a;
            for(auto i:ve)if(i!=s[0])a.push_back(i);
            ve=a;
        }
        vector<char>V;
        for(auto i:ve)if(!mp[i])V.push_back(i);
        v=V;
    }
    if(cnt>n+n/2)return "zob";
    return s;
  // std::string p = "";
  // for (int i = 0; i < 4 * N; ++i) {
  //   p += 'A';
  // }
  // int coins = press(p);
  // std::string S = "";
  // for (int i = 0; i < N; ++i) {
  //   S += 'A';
  // }
  // return S;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:13:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   13 |     while(s.size()!=n){
      |           ~~~~~~~~^~~
combo.cpp:16:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(int w=0;w<v.size();w++){
      |                     ~^~~~~~~~~
combo.cpp:30:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             if(k>s.size()){
      |                ~^~~~~~~~~
combo.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |                 if(k!=G.size()+F)mp[G[k-s.size()]]=1;
      |                    ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...