Submission #218138

# Submission time Handle Problem Language Result Execution time Memory
218138 2020-04-01T10:12:28 Z 2fat2code Password (RMI18_password) C++17
0 / 100
78 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 cnt[26];
queue<string>q;

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());
    for(int i=0;i<s;i++){
        string tz;
        for(int j=1;j<=n;j++) tz.push_back(i+'a');
        cnt[i] = query(tz);
    }
    for(int i=0;i<s;i++){
        string tz;
        for(int j=1;j<=cnt[i];j++) tz.push_back(i+'a');
        q.push(tz);
    }
    while(q.size()>=2){
        string t1=q.front();
        q.pop();
        string t2=q.front();
        string t3="";
        int i=0;
        for(int j=0;j<=t2.size();j++){
            string t4 = t2.substr(0,j) + t1[i] + t2.substr(j,t2.size()-j);
            if(query(t4)==t2.size()+1){
                t3.push_back(t1[i]);
                i++;
                if(i==t1.size()) break;
                j--;
            }
            else t3.push_back(t2[j]);
        }
        q.push(t3);
    }
    return q.front();
}

Compilation message

password.cpp: In function 'std::__cxx11::string guess(int, int)':
password.cpp:47:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int j=0;j<=t2.size();j++){
                     ~^~~~~~~~~~~
password.cpp:49:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(query(t4)==t2.size()+1){
                ~~~~~~~~~^~~~~~~~~~~~~
password.cpp:52:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(i==t1.size()) break;
                    ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 384 KB Token "dd
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 384 KB Token "bbbbbbaabbbbbbbbbbbbbbbbbbbbbbbbbb
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 384 KB Token "cccccccccccccccccccccccc
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 384 KB Token "dd
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 384 KB Token "dd
2 Halted 0 ms 0 KB -