Submission #519395

# Submission time Handle Problem Language Result Execution time Memory
519395 2022-01-26T10:08:37 Z hohohaha Password (RMI18_password) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h> 
using namespace std;
#define fori(i, a, b) for(int i = (int) (a); i <= (int) (b); i++)
#define ford(i, a, b) for(int i = (int) (a); i >= (int) (b); i--)
#define fi first
#define se second
#define all(x) begin(x), end(x)
#define ii pair<int, int>
#define pb push_back
#define pf push_front
#define em emplace
#define ef emplace_front
#define eb emplace_back
#define om pop
#define of pop_front
#define ob pop_back
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); 
#define rand rng
#define endl '\n'
#define sp ' '

#define int long long
const int maxn = 1e5 + 5, inf = LLONG_MAX / 100ll; 
int cnt[26]; 
int query(string s); 
string handle(int l, int r) { 
	if(l == r) { 
		string re; 
		char c = char(l + 'a'); 
		fori(i, 1, cnt[l]) re.push_back(c); 
		//cout << re << endl; 
		return re; 
	}
	else { 
		int m = l + r >> 1; 
		string L = handle(l, m);
		string R = handle(m + 1, r); 
		int q_num = 0, len = L.size() + R.size();
		int ptr = 0; 
		for(char C: R) { 
			while(1) { 
				if(ptr == L.size()) { 	
					L.insert(ptr, 1, C); 
					ptr++; 
					break; 
				}
				string tempL = L; tempL.insert(ptr, 1, C); 
				++q_num; assert(q_num <= len); 
				if(query(tempL) == tempL.size()) { 
					L = tempL; ptr++; 
					break; 
				}
				else { 
					ptr++; 
				}
			}
		}
		//cout << L << endl; 
		return L; 
	}
}
string guess(int n, int s)  { 
	fori(i, 0, s - 1) { 
		char c = char(i + 'a'); 
		string q; 
		fori(j, 1, n) q.push_back(c); 
		cnt[i] = query(q);
	}
	return handle(0, s - 1); 
}

Compilation message

password.cpp: In function 'std::string handle(long long int, long long int)':
password.cpp:35:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |   int m = l + r >> 1;
      |           ~~^~~
password.cpp:42:12: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if(ptr == L.size()) {
      |        ~~~~^~~~~~~~~~~
password.cpp:49:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     if(query(tempL) == tempL.size()) {
      |        ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc3w9pVM.o: in function `main':
grader.cpp:(.text.startup+0x66): undefined reference to `guess[abi:cxx11](int, int)'
collect2: error: ld returned 1 exit status