Submission #634895

# Submission time Handle Problem Language Result Execution time Memory
634895 2022-08-25T08:19:54 Z danikoynov Password (RMI18_password) C++14
0 / 100
7 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];
        }

        for (int i = 0; i < n - 1; i ++)
        {
            string cur = wt;
            cur.insert(cur.begin() + i, (char)(j + 'a'));
            int sm = query(cur);
            if (sm > len)
            {
                len = sm;
                ans = cur;
            }
        }

    }
    return ans;

}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:30:13: warning: unused variable 'id' [-Wunused-variable]
   30 |         int id = 0;
      |             ^~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 226 queries.
2 Runtime error 7 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 208 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 336 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 226 queries.
2 Runtime error 7 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 226 queries.
2 Runtime error 7 ms 208 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -