Submission #286937

# Submission time Handle Problem Language Result Execution time Memory
286937 2020-08-31T07:32:18 Z crossing0ver Password (RMI18_password) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;

int m;
string suf,pref;
int query(string str);
string guess(int n, int s) {
	string pref,P;
	for (int i = 1; i <= n; i++) {
		int len = suf.size() + pref().size();
		char LAST = ((int)pref.size() ? pref.back() : 'a');
		int cur = len;
		for (int z = 1; z + pref.size() + suf.size() <= n; z++) {
			bool flag = 0;
		for (char c = 'a'; c < 'a' + s; c++) {
			P = pref + c;
			P += suf;
			int F = query(P);
			if (F > cur) {
				LAST = c;
				pref += c;
				cur = F;
				flag  = 1;
				break;
			}
		}
		if (flag == 0) break;
		}
		reverse(all(suf));
		if (pref.size())
		suf+=pref.back();
		reverse(all(suf));
		if (pref.size())
		pref.pop_back();
		if (pref.size() + suf.size() == n) {
			pref += suf;
			int z = query(pref);
			if (z != n) {
				while(true) {
					
				}
			}
			return pref;
		}
	}
	return suf;
}
/*
main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

}*/

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:17:31: error: no match for call to '(std::string {aka std::__cxx11::basic_string<char>}) ()'
   17 |   int len = suf.size() + pref().size();
      |                               ^
password.cpp:20:48: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |   for (int z = 1; z + pref.size() + suf.size() <= n; z++) {
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
password.cpp:42:32: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |   if (pref.size() + suf.size() == n) {
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~