Submission #848780

# Submission time Handle Problem Language Result Execution time Memory
848780 2023-09-13T13:38:26 Z TahirAliyev Password (RMI18_password) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "grader.cpp"

using namespace std;

vector<string> v;

string merge(string a, string b){
    int p1 = 0, p2 = 0;
    while(p1 <= a.size() && p2 < b.size()){
        string q = a;
        q.insert(q.begin() + p1, b[p2]);
        if(query(q) == q.size()){
            a = q;
            p2++;
        }
        else{
            p1++;
        }
    }
    return a;
}

string guess(int n, int s){
    for(char c = 'a'; c <= 'a' + s - 1; c++){
        string s = "";
        for(int i = 1; i <= n; i++){
            s += c;
        }
        int cnt = query(s);
        s = "";
        for(int i = 1; i <= cnt; i++){
            s += c;
        }
        v.push_back(s);
    }
    string main = v[0];
    for(int i = 1; i < v.size(); i++){
        main = merge(main, v[i]);
    }
    return main;
}

Compilation message

password.cpp: In function 'std::string merge(std::string, std::string)':
password.cpp:10:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     while(p1 <= a.size() && p2 < b.size()){
      |           ~~~^~~~~~~~~~~
password.cpp:10:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     while(p1 <= a.size() && p2 < b.size()){
      |                             ~~~^~~~~~~~~~
password.cpp:13:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         if(query(q) == q.size()){
      |            ~~~~~~~~~^~~~~~~~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:38:22: 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]
   38 |     for(int i = 1; i < v.size(); i++){
      |                    ~~^~~~~~~~~~
/usr/bin/ld: /tmp/cca2K02d.o: in function `query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x80): multiple definition of `query(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/cc37H2Db.o:password.cpp:(.text+0x240): first defined here
/usr/bin/ld: /tmp/cca2K02d.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc37H2Db.o:password.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status