제출 #773151

#제출 시각아이디문제언어결과실행 시간메모리
773151aykhnPassword (RMI18_password)C++14
0 / 100
1 ms208 KiB
#include <bits/stdc++.h>
 
// author: aykhn
 
using namespace std;
 
typedef long long ll;
 
int query(string str);
 
string guess(int n, int s)
{
    string ans = "";
    int prev;
 
    string x = "a";
    for (int i = 0; i < s; i++)
    {
        ans = x + ans;
        int X = query(ans);
        prev = max(X, prev);
        if (!X) ans = ans.substr(1, (int)(ans.length()) - 1);
 
        for (int j = 1; j <= ans.length(); j++)
        {
            string asd = ans.substr(0, j);
            string assd = "";
            ans = asd;
            asd += x;
            asd += assd;
            int y = query(ans);
            if (y <= prev)
            {
                asd = ans.substr(0, j);
                assd = "";
                ans = asd + assd;
            }
        }
 
        x[0]++;
    }
 
    return ans;
}

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

password.cpp: In function 'std::string guess(int, int)':
password.cpp:24:27: 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 j = 1; j <= ans.length(); j++)
      |                         ~~^~~~~~~~~~~~~~~
password.cpp:14:9: warning: 'prev' may be used uninitialized in this function [-Wmaybe-uninitialized]
   14 |     int prev;
      |         ^~~~
#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...