답안 #722696

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722696 2023-04-12T16:43:42 Z groshi Password (RMI18_password) C++17
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;
priority_queue<pair<int,string> > kolejka;
string marge(string a,string b)
{
    string wypisz="";
    int l=0,r=0;
    while(l<a.length() || r<b.length())
    {
        if(l==a.length())
        {
            wypisz+=b[r];
            r++;
            continue;
        }
        if(r==b.length())
        {
            wypisz+=a[l];
            l++;
            continue;
        }
        string posiadam="";
        for(int i=l;i<a.length();i++)
            posiadam+=a[i];
        int ile=query(wypisz+b[r]+posiadam);
        if(ile==wypisz.length()+1+posiadam.length())
        {
            wypisz+=b[r];
            r++;
            continue;
        }
        else{
            wypisz+=a[l];
            l++;
            continue;
        }
    }
    return wypisz;
}
string guess(int n,int s)
{
    for(int i=0;i<s;i++)
    {
        string pom="";
        for(int j=1;j<=n;j++)
            pom+=(char)('a'+i);
        int ile=query(pom);
        string mam="";
        for(int j=1;j<=ile;j++)
            mam+=(char)('a'+i);
        if(ile!=0)
            kolejka.push({-ile,mam});
    }
    while(kolejka.size()>=2)
    {
        auto para1=kolejka.top();
        kolejka.pop();
        auto para2=kolejka.top();
        kolejka.pop();
        string mam=marge(para1.second,para2.second);
        kolejka.push({-mam.length(),mam});
    }
    return kolejka.top().second;
}

Compilation message

password.cpp: In function 'std::string marge(std::string, std::string)':
password.cpp:9:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     while(l<a.length() || r<b.length())
      |           ~^~~~~~~~~~~
password.cpp:9:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     while(l<a.length() || r<b.length())
      |                           ~^~~~~~~~~~~
password.cpp:11:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         if(l==a.length())
      |            ~^~~~~~~~~~~~
password.cpp:17:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         if(r==b.length())
      |            ~^~~~~~~~~~~~
password.cpp:24:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int i=l;i<a.length();i++)
      |                     ~^~~~~~~~~~~
password.cpp:26:17: error: 'query' was not declared in this scope
   26 |         int ile=query(wypisz+b[r]+posiadam);
      |                 ^~~~~
password.cpp:27:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         if(ile==wypisz.length()+1+posiadam.length())
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:48:17: error: 'query' was not declared in this scope
   48 |         int ile=query(pom);
      |                 ^~~~~