제출 #641167

#제출 시각아이디문제언어결과실행 시간메모리
641167Tenis0206Password (RMI18_password)C++14
50 / 100
450 ms604 KiB
#include <bits/stdc++.h>

//#define home

using namespace std;

int query(string s);

#ifdef home

string str;

int query(string s)
{
    int j = 0;
    for(int i=0;i<s.size();i++)
    {
        while(j<str.size() && s[i]!=str[j])
        {
            ++j;
        }
        if(j==str.size())
        {
            return i;
        }
        ++j;
    }
    return s.size();
}

#endif // home

string s[205];

string Merge(string a, string b)
{
    int i = 0, j = 0;
    string rez;
    while(i<a.size() && j<b.size())
    {
        string aux = rez + a[i];
        for(int p=j;p<b.size();p++)
        {
            aux.push_back(b[p]);
        }
        int nr = query(aux);
        if(nr==aux.size())
        {
            rez.push_back(a[i]);
            ++i;
        }
        else
        {
            rez.push_back(b[j]);
            ++j;
        }
    }
    while(i<a.size())
    {
        rez.push_back(a[i]);
        ++i;
    }
    while(j<b.size())
    {
        rez.push_back(b[j]);
        ++j;
    }
    return rez;
}

string guess(int n, int cr)
{
    for(int c='a';c<='a'+cr-1;c++)
    {
        string aux;
        for(int j=1;j<=n;j++)
        {
            aux.push_back(c);
        }
        int nr = query(aux);
        for(int j=1;j<=nr;j++)
        {
            s[c].push_back(c);
        }
    }
    string rez;
    for(int c='a';c<='a'+cr-1;c++)
    {
        rez = Merge(rez,s[c]);
    }
    return rez;
}

#ifdef home

int main()
{
    cin>>str;
    cout<<guess(str.size(),4)<<'\n';
    return 0;
}

#endif // home

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

password.cpp: In function 'std::string Merge(std::string, std::string)':
password.cpp:39:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     while(i<a.size() && j<b.size())
      |           ~^~~~~~~~~
password.cpp:39:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     while(i<a.size() && j<b.size())
      |                         ~^~~~~~~~~
password.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(int p=j;p<b.size();p++)
      |                     ~^~~~~~~~~
password.cpp:47:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         if(nr==aux.size())
      |            ~~^~~~~~~~~~~~
password.cpp:58:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     while(i<a.size())
      |           ~^~~~~~~~~
password.cpp:63:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     while(j<b.size())
      |           ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...