답안 #218053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218053 2020-03-31T18:36:59 Z 2fat2code Password (RMI18_password) C++17
30 / 100
415 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];

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 empt="";
        for(int j=1;j<=n;j++) empt.push_back(i+'a');
        cnt[i]=query(empt);
    }
    string ans;
    while(ans.size()!=n){
        for(int i=0;i<=ans.size();i++){
            for(int j=0;j<tz.size();j++){
                if(cnt[tz[j]-'a']){
                    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);
                        cnt[tz[j]-'a']--;
                        goto next;
                    }
                }
            }
        }
        next:;
    }
    return ans;
}

Compilation message

password.cpp: In function 'std::__cxx11::string guess(int, int)':
password.cpp:38:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(ans.size()!=n){
           ~~~~~~~~~~^~~
password.cpp:39:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<=ans.size();i++){
                     ~^~~~~~~~~~~~
password.cpp:40:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0;j<tz.size();j++){
                         ~^~~~~~~~~~
password.cpp:43:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                     if(query(ask)==ans.size()+1){
                        ~~~~~~~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Guessed the password with 502 queries.
2 Correct 23 ms 384 KB Guessed the password with 1726 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 384 KB Guessed the password with 475 queries.
2 Correct 21 ms 384 KB Guessed the password with 1439 queries.
3 Correct 8 ms 384 KB Guessed the password with 347 queries.
4 Correct 107 ms 384 KB Guessed the password with 12146 queries.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 415 ms 384 KB Could not guess the password with 50000 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Guessed the password with 502 queries.
2 Correct 23 ms 384 KB Guessed the password with 1726 queries.
3 Correct 7 ms 384 KB Guessed the password with 475 queries.
4 Correct 21 ms 384 KB Guessed the password with 1439 queries.
5 Correct 8 ms 384 KB Guessed the password with 347 queries.
6 Correct 107 ms 384 KB Guessed the password with 12146 queries.
7 Incorrect 415 ms 384 KB Could not guess the password with 50000 queries.
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 384 KB Guessed the password with 502 queries.
2 Correct 23 ms 384 KB Guessed the password with 1726 queries.
3 Correct 7 ms 384 KB Guessed the password with 475 queries.
4 Correct 21 ms 384 KB Guessed the password with 1439 queries.
5 Correct 8 ms 384 KB Guessed the password with 347 queries.
6 Correct 107 ms 384 KB Guessed the password with 12146 queries.
7 Incorrect 415 ms 384 KB Could not guess the password with 50000 queries.
8 Halted 0 ms 0 KB -