Submission #520394

# Submission time Handle Problem Language Result Execution time Memory
520394 2022-01-29T18:36:54 Z Alex_tz307 Password (RMI18_password) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
 
using namespace std;
 
struct sir {
  string s;
 
  sir() : s("") {}
 
  bool operator < (const sir &a) const {
    return s.size() > a.s.size();
  };
};
 
void test_case() {
  int n, m;
  cin >> n >> m;
  priority_queue<sir> pq;
  int sum_freq = 0;
  for (int i = 0; i <= m - 1; ++i) {
    char c = i + 97;
    int freq;
    if (i <= m - 2) {
      for (int j = 0; j <= n - 1; ++j) {
        cout << c;
      }
      cout << endl;
      cin >> freq;
      sum_freq += freq;
    } else {
      freq = n - sum_freq;
    }
    sir a;
    for (int j = 0; j <= freq - 1; ++j) {
      a.s += c;
    }
    pq.push(a);
  }
  while ((int)pq.size() >= 2) {
    sir a = pq.top();
    pq.pop();
    sir b = pq.top();
    pq.pop();
    sir c;
    while (a.s.empty() == false && b.s.empty() == false) {
      cout << c.s << a.s[0] << b.s << endl;
      int len;
      cin >> len;
      if (len == 1 + c.s.size() + b.s.size()) {
        c.s += a.s[0];
        a.s.erase(a.s.begin());
      } else {
        c.s += b.s[0];
        b.s.erase(b.s.begin());
      }
    }
    c.s += a.s;
    c.s += b.s;
    pq.push(c);
  }
  cout << pq.top().s << endl;
  int len;
  cin >> len;
}
 
int main() {
  int t = 1;
  for (int tc = 1; tc <= t; ++tc) {
    test_case();
  }
  return 0;
}

Compilation message

password.cpp: In function 'void test_case()':
password.cpp:49:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |       if (len == 1 + c.s.size() + b.s.size()) {
      |           ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccB1UQSz.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc0ew05z.o:password.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccB1UQSz.o: in function `main':
grader.cpp:(.text.startup+0x66): undefined reference to `guess[abi:cxx11](int, int)'
collect2: error: ld returned 1 exit status