답안 #218148

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218148 2020-04-01T10:24:51 Z 2fat2code Password (RMI18_password) C++17
0 / 100
48 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');
        if(tz.size()) q.push(tz);
    }
    while(q.size()>=2){
        string t1=q.front();
        q.pop();
        string t2=q.front();
        string pref="";
        int i=0;
        for(int j=0;j<=t2.size();j++){
            string t4 = pref + t1[i] + t2.substr(j,t2.size()-j);
            if(query(t4)==(t2.size()+i+1)){
                pref.push_back(t1[i]);
                i++;
                if(i==t1.size()){
                    pref+=t2.substr(j,t2.size()-j);
                    break;
                }
                j--;
            }
        }
        q.push(pref);
    }
    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()+i+1)){
                ~~~~~~~~~^~~~~~~~~~~~~~~~~
password.cpp:52:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(i==t1.size()){
                    ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 384 KB Token "
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 48 ms 384 KB Token "
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 46 ms 384 KB Token "
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 384 KB Token "
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 384 KB Token "
2 Halted 0 ms 0 KB -