Submission #755875

# Submission time Handle Problem Language Result Execution time Memory
755875 2023-06-10T17:07:43 Z vjudge1 Password (RMI18_password) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "C:\GCC\debug.h"
#else
#define debug(...) void(42)
#endif

int query(string str);

/*
int query(string str) {
  cout << str << endl;
  int x;
  cin >> x;
  return x;
}
*/

string guess(int n, int s) {
  string endChars;

  vector<int> freq(s);
  for (int i = 0; i < s; i++) {
    string str;
    for (int it = 0; it < n; it++) {
      str += (i + 'a');
    }
    freq[i] = query(str);
    if (freq[i] == n) {
      return str;
    }
  }

  string res;
  for (int i = 0; i < s; i++) {
    for (int j = 0; j < freq[i]; j++) {
      res += (i + 'a');
    }
  }

  auto Build = [&](char i, char j) {
    string str;
    str += i;
    str += j;
    return str;
  };

  sort(res.begin(), res.end(), [&](char i, char j) {
    if (i == j) {
      return 0;
    }
    return (query(Build(i, j)) == 2);
  });

  return res;
}

/*
int main() {
  guess(5, 5);
}
*/

Compilation message

password.cpp: In lambda function:
password.cpp:55:32: error: inconsistent types 'int' and 'bool' deduced for lambda return type
   55 |     return (query(Build(i, j)) == 2);
      |            ~~~~~~~~~~~~~~~~~~~~^~~~~