結果

問題 No.2768 Password Crack
ユーザー 👑 hos.lyrichos.lyric
提出日時 2024-05-31 22:00:19
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,839 bytes
コンパイル時間 2,863 ms
コンパイル使用メモリ 119,608 KB
実行使用メモリ 25,220 KB
平均クエリ数 1714.80
最終ジャッジ日時 2024-05-31 22:00:30
合計ジャッジ時間 6,985 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
25,196 KB
testcase_01 AC 22 ms
24,580 KB
testcase_02 AC 92 ms
25,220 KB
testcase_03 AC 95 ms
24,580 KB
testcase_04 AC 92 ms
24,580 KB
testcase_05 AC 38 ms
25,220 KB
testcase_06 AC 116 ms
25,220 KB
testcase_07 AC 93 ms
24,964 KB
testcase_08 AC 40 ms
24,580 KB
testcase_09 AC 93 ms
25,220 KB
testcase_10 AC 93 ms
24,964 KB
testcase_11 AC 89 ms
24,836 KB
testcase_12 AC 94 ms
24,964 KB
testcase_13 AC 95 ms
24,836 KB
testcase_14 AC 116 ms
25,220 KB
testcase_15 AC 113 ms
24,824 KB
testcase_16 AC 92 ms
25,220 KB
testcase_17 AC 91 ms
24,656 KB
testcase_18 AC 93 ms
24,580 KB
testcase_19 AC 62 ms
24,580 KB
testcase_20 AC 61 ms
25,220 KB
testcase_21 AC 113 ms
24,836 KB
testcase_22 AC 81 ms
25,208 KB
testcase_23 AC 34 ms
25,220 KB
testcase_24 AC 51 ms
24,836 KB
testcase_25 AC 104 ms
24,964 KB
testcase_26 AC 53 ms
25,204 KB
testcase_27 AC 75 ms
24,580 KB
testcase_28 AC 36 ms
25,220 KB
testcase_29 AC 41 ms
24,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }

string COLOR(string s = "") { return "\x1b[" ~ s ~ "m"; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


debug {
enum A = 4;
} else {
enum A = 26;
}

int ask(char[] cs) {
  writeln("? ", cs); stdout.flush;
  const res = readInt;
  return res;
}

void main() {
  const N = readInt;
  auto cs = new char[N];
  cs[] = 'a';
  const base = ask(cs);
  
  auto ans = new char[N];
  ans[] = cast(char)('a' + (A - 1));
  foreach (i; 0 .. N) {
    auto fs = new int[A - 1];
    fs[0] = base;
    foreach (a; 1 .. A - 1) {
      cs[i] = cast(char)('a' + a);
      fs[a] = ask(cs);
      cs[i] = 'a';
    }
    const minF = fs.minElement;
    foreach (a; 0 .. A - 1) if (minF < fs[a]) {
      ans[i] = cast(char)('a' + a);
    }
  }
  writeln("! ", ans); stdout.flush;
}
0