Submission #918618

# Submission time Handle Problem Language Result Execution time Memory
918618 2024-01-30T07:45:01 Z AtabayRajabli Password (RMI18_password) C++17
0 / 100
1 ms 344 KB
#include <bits/stdc++.h>
using namespace std;

int query(string s);

string guess(int n, int s)
{
    int comb[s][s] = {0};
    int freq[s] = {0};

    for(int i = 0; i < s; i++)
    {
        int l = 0, r = n;
        while(l <= r)
        {
        int mid = (l + r) / 2;
        string x = "";
        for(int j = 0; j < mid; j++)x += (char(i + 'a'));

        int sz = x.size();
        if(query(x) == sz)l = mid + 1;
        else r = mid - 1;
        }
        freq[i] = l - 1;
    }

    string ans = "";
    for(int i = 0; i < s; i++)
    {
        for(int j = 0; j < s; j++)
        {
            string x = "";
            x += char(i + 'a');
            int cnt = freq[j];
            while(cnt--)x += char(j + 'a');

            comb[i][j] = query(x);
        }
    }

    for(int ind = 0; ind < n; ind++)
    {
        for(int i = 0; i < s; i++)
        {
            bool check = 1;
            for(int j = 0; j < s; j++)
            {
                if(comb[i][j] != freq[j] + 1)
                {
                    check = 0;
                    break;
                }
            }
            if(check)
            {
                ans += char(i + 'a');
                freq[i]--;
                break;
            }
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Token "-1" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Token "-1" doesn't correspond to pattern "[a-b]{1,50}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Token "-1" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Token "-1" doesn't correspond to pattern "[a-o]{1,15}"
2 Halted 0 ms 0 KB -