답안 #288073

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
288073 2020-09-01T08:31:55 Z achibasadzishvili Password (RMI18_password) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define ll int
#define f first
#define s second
#define pb push_back
using namespace std;
/*
ll query(string x){
    return 0;
}
*/
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);
    }
    while(v.size() > 1){
        vector<string>v1;
        for(int i0=0; i0<v.size(); i0+=2){
            int i1 = i0 + 1;
            ll l = 0,r = 0;
            string cur = "";
            while(l < v[i0].size() && r < v[i1].size()){
                string ne = cur;
                ne += v[i0][l];
                for(int i=r; i<v[i1].size(); i++)ne += v[i1][i];
                ll t = query(ne);
                if(t == l + 1 + v[i1].size()){
                    cur += v[i0][l];
                    l++;
                }
                else {
                    cur += v[i1][r];
                    r++;
                }
            }
            v1.pb(cur);
        }
        v = v1;
    }
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:20:19: error: 'query' was not declared in this scope
   20 |         raod[i] = query(k);
      |                   ^~~~~
password.cpp:27:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(int i0=0; i0<v.size(); i0+=2){
      |                       ~~^~~~~~~~~
password.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             while(l < v[i0].size() && r < v[i1].size()){
      |                   ~~^~~~~~~~~~~~~~
password.cpp:31:41: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             while(l < v[i0].size() && r < v[i1].size()){
      |                                       ~~^~~~~~~~~~~~~~
password.cpp:34:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |                 for(int i=r; i<v[i1].size(); i++)ne += v[i1][i];
      |                              ~^~~~~~~~~~~~~
password.cpp:35:24: error: 'query' was not declared in this scope
   35 |                 ll t = query(ne);
      |                        ^~~~~
password.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |                 if(t == l + 1 + v[i1].size()){
      |                    ~~^~~~~~~~~~~~~~~~~~~~~~~
password.cpp:49:1: warning: no return statement in function returning non-void [-Wreturn-type]
   49 | }
      | ^