답안 #493869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493869 2021-12-13T09:08:30 Z dekanycsaba Password (RMI18_password) C++14
0 / 100
3000 ms 3184 KB
#include <iostream>
#include <bits/stdc++.h>
#include<string>
#include<set>
#include<iterator>

using namespace std;

int s1, s2;
string p1, p2;
string megold;
int query(string str);

struct szov
{
    string ir;
    int hosz=0;

};

struct rendez{

bool operator()(szov const& a, szov const& b)
{
    return a.hosz<b.hosz;
}

};

multiset<szov,rendez> ms1;
multiset<szov,rendez>::iterator itr;

szov proba;

string merging(string f1, string f2)
{
    string a3;
    string e1,e2;
    string ossz;
    while(!f1.empty() || !f2.empty())
    {
        if(f1.empty())
        {
            a3=a3+f2;
        }
        else if(f2.empty())
        {
            a3=a3+f1;
        }
        else{
            e1=f1[0];
            e2=f2[0];
            ossz=a3+e1+f2;
            s2=query(ossz);
            if(s2==ossz.size())
            {
                a3=a3+e1;
                f1.erase(f1.begin());
            }
            else{
                a3=a3+e2;
                f2.erase(f2.begin());
            }
        }
    }

    return a3;
}

string guess(int N, int S)
{
    string help="aabcdefghijklmnopqrstuvwxyz";
    string T[27]={};
    for(int j=1;j<N+1;j++)
    {
        for(int i=1;i<S+1;i++)
    {
        T[i]=T[i]+help[i];
    }
    }
    for(int i=1;i<S+1;i++)
    {
        s1=query(T[i]);
        if(s1>0)
        {
            proba.hosz=s1;
            proba.ir.clear();
            for(int j=1;j<s1+1;j++)
            {
                proba.ir=proba.ir+help[i];
            }
            ms1.insert(proba);
        }
    }
    while(ms1.size()>1)
    {
        itr=ms1.begin();
        p1=(*itr).ir;
        ms1.erase(itr);
        itr=ms1.begin();
        p2=(*itr).ir;
        proba.hosz=p1.size()+p2.size();
        proba.ir=merging(p1,p2);
        ms1.insert(proba);
    }
    if(ms1.size()==1)
    {
         itr=ms1.begin();
         megold=(*itr).ir;
    }

return megold;
}

Compilation message

password.cpp: In function 'std::string merging(std::string, std::string)':
password.cpp:55:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             if(s2==ossz.size())
      |                ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3058 ms 2764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3052 ms 3184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3053 ms 2420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3058 ms 2764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3058 ms 2764 KB Time limit exceeded
2 Halted 0 ms 0 KB -