답안 #634901

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
634901 2022-08-25T08:23:33 Z danikoynov Password (RMI18_password) C++14
0 / 100
3000 ms 336 KB
#include<bits/stdc++.h>
using namespace std;

const int maxs = 26;
int N, S, used[maxs];

int query(string s);
string guess(int n, int s)
{
    N = n;
    S = s;
    string ans = "";

    for (int i = 0; i < s; i ++)
    {
        string cur = "";
        for (int j = 0; j < n; j ++)
            cur = cur + (char)(i + 'a');

        if (query(cur) == 1)
            ans = ans + (char)(i + 'a'), used[i] = 1;
    }


    int len = query(ans);
    for (int j = 0; j < s; j ++)
    {
        if (!used[j])
            continue;
        int id = 0;
        string wt = "";
        for (int i = 0; i < n; i ++)
        {
            if (ans[i] != (char)(j + 'a'))
                wt = wt + ans[i];
        }

        if (wt.size() != n -1)
            while(true);

            continue;
        for (int i = 0; i < n; i ++)
        {
            string cur = wt, new_cur = "";
            for (int k = 0; k < n; k ++)
            {
                if (i == k)
                    new_cur = new_cur + (char)(j + 'a');
                if (k != n - 1)
                    new_cur = new_cur + cur[k];
            }
            int sm = query(new_cur);
            if (sm > len)
            {
                len = sm;
                ans = new_cur;
            }
        }

    }
    return ans;

}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:38:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         if (wt.size() != n -1)
      |             ~~~~~~~~~~^~~~~~~
password.cpp:38:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   38 |         if (wt.size() != n -1)
      |         ^~
password.cpp:41:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   41 |             continue;
      |             ^~~~~~~~
password.cpp:30:13: warning: unused variable 'id' [-Wunused-variable]
   30 |         int id = 0;
      |             ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 17 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 0 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3068 ms 336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 17 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 17 queries.
2 Halted 0 ms 0 KB -