제출 #288089

#제출 시각아이디문제언어결과실행 시간메모리
288089achibasadzishviliPassword (RMI18_password)C++14
100 / 100
362 ms668 KiB
#include<bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
string s;
int query(string str);
string guess(int n,int s){
    ll raod[40];
    for(int i=0; i<30; i++)raod[i] = 0;
    vector<string>v;
    for(int i=0; i<s; i++){
        char c = char('a' + i);
        string k;
        for(int j=0; j<n; j++)k += c;
        raod[i] = query(k);
        k = "";
        for(int j=0; j<raod[i]; j++)k += c;
        if(k.size())v.pb(k);
    }
    string ne;
    ll t;
    while(v.size() > 1){
        vector<string>v1;
        for(int i0=0; i0<(int)v.size()-1; i0+=2){
            int i1 = i0 + 1;
            ll l = 0,r = 0;
            string cur = "";
            while(l < v[i0].size() && r < v[i1].size()){
                ne = cur;
                ne += v[i0][l];
                for(int i=r; i<v[i1].size(); i++)ne += v[i1][i];
                t = query(ne);
                if(t == l + 1 + v[i1].size()){
                    cur += v[i0][l];
                    l++;
                }
                else {
                    cur += v[i1][r];
                    r++;
                }
            }
            while(l < v[i0].size()){
                cur += v[i0][l];
                l++;
            }
            while(r < v[i1].size()){
                cur += v[i1][r];
                r++;
            }
            v1.pb(cur);
        }
        if(v.size()%2==1)v1.pb(v.back());
        v = v1;
    }
    return v[0];
}

컴파일 시 표준 에러 (stderr) 메시지

password.cpp: In function 'std::string guess(int, int)':
password.cpp:30:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             while(l < v[i0].size() && r < v[i1].size()){
      |                   ~~^~~~~~~~~~~~~~
password.cpp:30:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             while(l < v[i0].size() && r < v[i1].size()){
      |                                       ~~^~~~~~~~~~~~~~
password.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |                 for(int i=r; i<v[i1].size(); i++)ne += v[i1][i];
      |                              ~^~~~~~~~~~~~~
password.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |                 if(t == l + 1 + v[i1].size()){
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~~
password.cpp:44:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             while(l < v[i0].size()){
      |                   ~~^~~~~~~~~~~~~~
password.cpp:48:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             while(r < v[i1].size()){
      |                   ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...