Submission #755886

# Submission time Handle Problem Language Result Execution time Memory
755886 2023-06-10T17:19:37 Z vjudge1 Password (RMI18_password) C++17
30 / 100
400 ms 432 KB
#include <bits/stdc++.h>
 
        using namespace std;
 
        int query(string q);
        string guess(int n, int s) {
            string S(n, 'a');
            int freq[s], used[s]{0}; vector<int> p;
            for(int l = 0; l < s; l++) {
                for(int i = 0; i < n; i++)
                    S[i] = char(l + 'a');
                freq[l] = query(S);
                if(freq[l] > 0) p.push_back(l);
            }
            S = "";
            for(int l = 0; l < n; l++) {
                S.push_back('a');
                for(int i = 0; i < s; i++) {
                    if(used[i] == freq[i]) continue;
                    S[l] = char(i + 'a');
                    if(l < n - 1) {
                        used[i]++; int cnt = 0, tr = 0;
                        for(int j = 0; j < s; j++) {
                            if(used[j] == freq[j]) continue;
                            if(cnt < tr) { tr++; continue; }
                            tr++;
                            for(int e = used[j] + 1; e <= freq[j]; e++)
                                S.push_back(char(j + 'a'));
                            int R = query(S); 
                          	if(R == n) return S;
                          	R -= l;
                            cnt += (R == 1 + freq[j] - used[j]);
                            for(int e = used[j] + 1; e <= freq[j]; e++)
                                S.pop_back();
                        }
                        used[i]--;
                        if(cnt == tr){
                            used[i]++;
                            break;
                        }
                    }
                }
            }
            return S;
        }
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 242 queries.
2 Correct 3 ms 208 KB Guessed the password with 536 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 145 queries.
2 Correct 4 ms 208 KB Guessed the password with 273 queries.
3 Correct 5 ms 208 KB Guessed the password with 567 queries.
4 Correct 6 ms 208 KB Guessed the password with 733 queries.
# Verdict Execution time Memory Grader output
1 Correct 196 ms 432 KB Guessed the password with 33285 queries.
2 Correct 260 ms 428 KB Guessed the password with 46053 queries.
3 Incorrect 400 ms 312 KB Could not guess the password with 50000 queries.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 242 queries.
2 Correct 3 ms 208 KB Guessed the password with 536 queries.
3 Correct 1 ms 208 KB Guessed the password with 145 queries.
4 Correct 4 ms 208 KB Guessed the password with 273 queries.
5 Correct 5 ms 208 KB Guessed the password with 567 queries.
6 Correct 6 ms 208 KB Guessed the password with 733 queries.
7 Correct 196 ms 432 KB Guessed the password with 33285 queries.
8 Correct 260 ms 428 KB Guessed the password with 46053 queries.
9 Incorrect 400 ms 312 KB Could not guess the password with 50000 queries.
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 242 queries.
2 Correct 3 ms 208 KB Guessed the password with 536 queries.
3 Correct 1 ms 208 KB Guessed the password with 145 queries.
4 Correct 4 ms 208 KB Guessed the password with 273 queries.
5 Correct 5 ms 208 KB Guessed the password with 567 queries.
6 Correct 6 ms 208 KB Guessed the password with 733 queries.
7 Correct 196 ms 432 KB Guessed the password with 33285 queries.
8 Correct 260 ms 428 KB Guessed the password with 46053 queries.
9 Incorrect 400 ms 312 KB Could not guess the password with 50000 queries.
10 Halted 0 ms 0 KB -