Submission #218051

# Submission time Handle Problem Language Result Execution time Memory
218051 2020-03-31T18:22:56 Z 2fat2code Password (RMI18_password) C++17
30 / 100
421 ms 384 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define mp make_pair
//#define int long long
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

const int mod=1e9+7;
const int modp=1999999973;
const int modulo=998244353;

int query(string str);

string guess(int n,int s){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    vector<char>tz;
    for(int i=0;i<s;i++){
        tz.push_back(i+'a');
    }
    string ans;
    while(ans.size()!=n){
        for(int i=0;i<=ans.size();i++){
            random_shuffle(all(tz));
            for(int j=0;j<tz.size();j++){
                string ask = ans.substr(0,i) + tz[j] + ans.substr(i,ans.size()-i);
                if(query(ask)==ans.size()+1){
                    ans=ans.substr(0,i) + tz[j] +ans.substr(i,ans.size()-i);
                    goto next;
                }
            }
        }
        next:;
    }
    return ans;
}

Compilation message

password.cpp: In function 'std::__cxx11::string guess(int, int)':
password.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(ans.size()!=n){
           ~~~~~~~~~~^~~
password.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<=ans.size();i++){
                     ~^~~~~~~~~~~~
password.cpp:36:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0;j<tz.size();j++){
                         ~^~~~~~~~~~
password.cpp:38:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(query(ask)==ans.size()+1){
                    ~~~~~~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 384 KB Guessed the password with 1318 queries.
2 Correct 42 ms 384 KB Guessed the password with 4703 queries.
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB Guessed the password with 738 queries.
2 Correct 53 ms 384 KB Guessed the password with 5460 queries.
3 Correct 25 ms 384 KB Guessed the password with 2805 queries.
4 Correct 133 ms 384 KB Guessed the password with 16992 queries.
# Verdict Execution time Memory Grader output
1 Incorrect 421 ms 384 KB Could not guess the password with 50000 queries.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 384 KB Guessed the password with 1318 queries.
2 Correct 42 ms 384 KB Guessed the password with 4703 queries.
3 Correct 11 ms 384 KB Guessed the password with 738 queries.
4 Correct 53 ms 384 KB Guessed the password with 5460 queries.
5 Correct 25 ms 384 KB Guessed the password with 2805 queries.
6 Correct 133 ms 384 KB Guessed the password with 16992 queries.
7 Incorrect 421 ms 384 KB Could not guess the password with 50000 queries.
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 384 KB Guessed the password with 1318 queries.
2 Correct 42 ms 384 KB Guessed the password with 4703 queries.
3 Correct 11 ms 384 KB Guessed the password with 738 queries.
4 Correct 53 ms 384 KB Guessed the password with 5460 queries.
5 Correct 25 ms 384 KB Guessed the password with 2805 queries.
6 Correct 133 ms 384 KB Guessed the password with 16992 queries.
7 Incorrect 421 ms 384 KB Could not guess the password with 50000 queries.
8 Halted 0 ms 0 KB -