Submission #755966

# Submission time Handle Problem Language Result Execution time Memory
755966 2023-06-10T18:48:16 Z vjudge1 Password (RMI18_password) C++17
Compilation error
0 ms 0 KB
///YOU WILL MAKE IT
#include<bits/stdc++.h>
using namespace std;
int query(string s){
    int p1=0;
    string pass="abbb";
    for(int i=0;i<s.size();i++){
     if(p1<s.size()&&s[p1]==pass[i]){
        p1++;
     }
    }
    return p1;
};
string guess(int n,int s){
    string cur="";
    map<char,int> mp;
    for(int i=0;i<s;i++){
        string cur="";
        cur+=('a'+i);
        for(int j=1;j<=n;j++){
            if(query(cur)==j){
                mp[(i+'a')]++;
                cur+=(i+'a');
            }
        }
    }
    string ans="";
        for(int j=0;j<s;j++){
            bool f=1;
           // int val=0;
            for(int k=0;k<ans.size();k++){
                string temp=ans;
                //cout<<ans<<" "<<" "<<k<<" "<<temp<<endl;
                temp.insert(temp.begin()+k,(char)(j+'a'));
                if(query(temp)==temp.size()){
                    ans=temp;
                }
            }
            while(f){
                    f=0;
               string temp=ans;
                temp.push_back((char)(j+'a'));
                if(query(temp)==temp.size()){
                    ans=temp;
                    f=1;
                }
            }
        }
    return ans;
}
int main(){
    cout<<guess(4,2);
}

Compilation message

password.cpp: In function 'int query(std::string)':
password.cpp:7:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=0;i<s.size();i++){
      |                 ~^~~~~~~~~
password.cpp:8:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |      if(p1<s.size()&&s[p1]==pass[i]){
      |         ~~^~~~~~~~~
password.cpp: In function 'std::string guess(int, int)':
password.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for(int k=0;k<ans.size();k++){
      |                         ~^~~~~~~~~~~
password.cpp:35:31: 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(query(temp)==temp.size()){
      |                    ~~~~~~~~~~~^~~~~~~~~~~~~
password.cpp:43:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |                 if(query(temp)==temp.size()){
      |                    ~~~~~~~~~~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccaOjQ8q.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/ccH35eKs.o:password.cpp:(.text+0x290): first defined here
/usr/bin/ld: /tmp/ccaOjQ8q.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccH35eKs.o:password.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status