Submission #643119

# Submission time Handle Problem Language Result Execution time Memory
643119 2022-09-21T09:01:48 Z TimDee Password (RMI18_password) C++17
10 / 100
6 ms 208 KB
#include <bits/stdc++.h>
using namespace std;

int query(string s);

string guess(int n, int c) {

  if (c==2) {
    string A(n,'a'), B(n,'b');
    int a=query(A),b=query(B);
    string ans;
    int added=0;
    for (int i=a; i>=0; --i) {
      string s;
      for (int j=0; j<i; ++j) s+='a';
      for (int j=i; j<n; ++j) s+='b';
      int x=query(s);
      for (int j=0; j<x-added-i; ++j) ans+='b';
      ans+='a';
      added=x-i;
    }
    ans.pop_back();
    reverse(ans.begin(), ans.end());
    return ans;
  }

  if (n<=c && c<=26) {
    string ans(n,'.');
    for (char i='a'; i<'a'+c; ++i) {
      int x=0;
      for (char j='a'; j<'a'+c; ++j) {
        if (j==i) continue;
        string s;
        s+=i; s+=j;
        int q=query(s);
        x+=q-1;
      }
      if (x<0) continue;
      ans[n-1-x]=i;
    }
    return ans;
  }
}

Compilation message

password.cpp: In function 'std::string guess(int, int)':
password.cpp:10:20: warning: unused variable 'b' [-Wunused-variable]
   10 |     int a=query(A),b=query(B);
      |                    ^
password.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 211 queries.
2 Correct 6 ms 208 KB Guessed the password with 507 queries.
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Guessed the password with 28 queries.
2 Incorrect 0 ms 208 KB Token ".............................................................c.." doesn't correspond to pattern "[a-c]{1,70}"
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 208 KB Token "....................................................l...b......." doesn't correspond to pattern "[a-l]{1,1000}"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 211 queries.
2 Correct 6 ms 208 KB Guessed the password with 507 queries.
3 Correct 1 ms 208 KB Guessed the password with 28 queries.
4 Incorrect 0 ms 208 KB Token ".............................................................c.." doesn't correspond to pattern "[a-c]{1,70}"
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 208 KB Guessed the password with 211 queries.
2 Correct 6 ms 208 KB Guessed the password with 507 queries.
3 Correct 1 ms 208 KB Guessed the password with 28 queries.
4 Incorrect 0 ms 208 KB Token ".............................................................c.." doesn't correspond to pattern "[a-c]{1,70}"
5 Halted 0 ms 0 KB -