답안 #756907

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756907 2023-06-12T11:14:10 Z ElyesChaabouni Password (RMI18_password) C++17
10 / 100
305 ms 4304 KB
#include <bits/stdc++.h>
 
using namespace std;
vector<int> freq(1000005);
int query(string str);
 
string guess(int n, int s) {
  string endChars;
 
  
  for (int i = 0; i < s; i++) {
    string str;
    for (int it = 0; it < n; it++) {
      str += (i + 'a');
    }
    freq[i] = query(str);
  }
 
  for (int pos = n - 1; pos >= 0; pos--) {
    for (int i = 0; i < s; i++) {
      if (freq[i] > 0) {
        string build;
        for (int it = 0; it < freq[i]; it++) {
          build += (i + 'a');
        }
        bool work = true;
 
        if ((int) build.size() + 1 + (int) endChars.size() <= n) {
          for (int j = 0; j < s; j++) {
            string tmp;
            tmp += build;
            tmp += (j + 'a');
            tmp += endChars;
 
            if (query(tmp) == (int) tmp.length()) {
              work = false;
              break;
            }
          }
        }
 
        if (work) {
          freq[i] -= 1;
          string nEnd;
          nEnd += (i + 'a');
          nEnd += endChars;
          swap(nEnd, endChars);
          break;
        }
      }
    }
  }
  return endChars;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4176 KB Guessed the password with 427 queries.
2 Correct 15 ms 4176 KB Guessed the password with 1209 queries.
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4176 KB Guessed the password with 135 queries.
2 Runtime error 5 ms 4224 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 305 ms 4304 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4176 KB Guessed the password with 427 queries.
2 Correct 15 ms 4176 KB Guessed the password with 1209 queries.
3 Correct 3 ms 4176 KB Guessed the password with 135 queries.
4 Runtime error 5 ms 4224 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4176 KB Guessed the password with 427 queries.
2 Correct 15 ms 4176 KB Guessed the password with 1209 queries.
3 Correct 3 ms 4176 KB Guessed the password with 135 queries.
4 Runtime error 5 ms 4224 KB Execution killed with signal 13
5 Halted 0 ms 0 KB -