제출 #318059

#제출 시각아이디문제언어결과실행 시간메모리
318059nicolaalexandraPassword (RMI18_password)C++14
100 / 100
347 ms932 KiB
#include <bits/stdc++.h> using namespace std; int query(string str); priority_queue <pair<int,string> > h; int f[30]; /*int query (string s){ int ans; cout<<s<<"\n"; cin>>ans; return ans; } */ string guess (int n, int m){ /// aflu frecventa fiecarui caracter int i,j; for (i=1;i<=m;i++){ string v (n,i + 96); f[i] = query (v); string aux (f[i],i + 96); h.push(make_pair(-f[i],aux)); } /// dau merge la toate sirurile sortate while (h.size() >= 2){ int size1 = -h.top().first; string v = h.top().second; h.pop(); int size2 = -h.top().first; string w = h.top().second; h.pop(); string a = ""; i = 0, j = 0; while (i < v.length() && j < w.length()){ /// incerc sa pun v[i]; string aux = a; aux.push_back(v[i]); /// acum completez cu celalalt sir for (int poz=j;poz<w.length();poz++) aux.push_back(w[poz]); if (query(aux) == aux.length()){ a.push_back(v[i]); i++; } else { a.push_back(w[j]); j++; } } for (;i<v.length();i++) a.push_back(v[i]); for (;j<w.length();j++) a.push_back(w[j]); h.push(make_pair(-(size1+size2),a)); } return h.top().second; }

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

password.cpp: In function 'std::string guess(int, int)':
password.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         while (i < v.length() && j < w.length()){
      |                ~~^~~~~~~~~~~~
password.cpp:42:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         while (i < v.length() && j < w.length()){
      |                                  ~~^~~~~~~~~~~~
password.cpp:48:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for (int poz=j;poz<w.length();poz++)
      |                            ~~~^~~~~~~~~~~
password.cpp:51:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             if (query(aux) == aux.length()){
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~~
password.cpp:61:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for (;i<v.length();i++)
      |               ~^~~~~~~~~~~
password.cpp:63:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for (;j<w.length();j++)
      |               ~^~~~~~~~~~~
#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...