답안 #666344

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
666344 2022-11-28T08:42:31 Z Nursik Password (RMI18_password) C++14
0 / 100
15 ms 308 KB
#include <stdio.h>
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
#define ll long long
#define pb push_back
#define mp make_pair

int query(string str);
pair<int, string> combine(string a, string b){
    string ans = "";
    int i = 0, j = 0;
    int n = (int)a.size(), m = (int)b.size();
    int cl = m;
    while (i < n && j < m){
        string cur = "";
        cur += ans;
        cur += a[i];
        for (int pos = j; pos < m; ++pos){
            cur += b[pos];
        }
        int kek = query(cur);
        if (cl + 1 == kek){
            ans += a[i++];
        }
        else{
            ans += b[j++];
        }
        cl += 1;
    }
    for (int pos = j; pos < m; ++pos){
        ans += b[pos];
    }
    for (int pos = i; pos < n; ++pos){
        ans += a[pos];
    }
    return mp(n + m, ans);
}
string guess(int n, int s){
    multiset<pair<int, string>> setik;
    for (int i = 0; i < s; ++i){
        string q = "";
        char ch = 'a';
        ch += i;
        for (int j = 0; j < n; ++j){
            q += ch;
        }
        int kek = query(q);
        string w = "";
        for (int j = 1; j <= kek; ++j){
            w += ch;
        }
        if (kek){
            setik.insert(mp(kek, w));
        }
    }
    while (setik.size() != 1){
        pair<int, string> cur = *setik.begin();
        setik.erase(setik.find(cur));
        pair<int, string> cur2 = *setik.begin();
        setik.erase(setik.find(cur2));
        pair<int, string> ncur = combine(cur.second, cur2.second);
        setik.insert(ncur);
    }
    pair<int, string> ans = *setik.begin();
    return ans.second;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 49 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 29 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 15 ms 308 KB Returned early from guess() after 1546 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 49 queries.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Returned early from guess() after 49 queries.
2 Halted 0 ms 0 KB -