結果

問題 No.3752 No Use Crying Over Suffixes
コンテスト
ユーザー hos.lyric
提出日時 2026-10-02 23:40:50
言語 D
(dmd 2.113.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 162 ms / 2,000 ms
+ 520µs
コード長 3,119 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,703 ms
コンパイル使用メモリ 137,204 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2026-10-02 23:41:07
合計ジャッジ時間 5,441 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)); }



bool solve(const(int[]) A) {
  bool[2] f;
  f[0] = true;
  foreach_reverse (a; A) {
    if (a & 1) swap(f[0], f[1]);
    if (a == 1) f[1] = true;
  }
  return f[1];
}

void exper2() {
  enum N = 10;
  auto f = new bool[][](N, N);
  foreach (a; 0 .. N) foreach (b; 0 .. N) {
    if (a) {
      int aa = a - 1, bb = b;
      if (aa == 0) bb = 0;
      if (!f[aa][bb]) f[a][b] = true;
    }
    if (b) {
      int aa = a, bb = b - 1;
      if (bb == 0) {}
      if (!f[a][b - 1]) f[a][b] = true;
    }
  }
  foreach (a; 0 .. N) {
    writef("%2d ", a);
    foreach (b; 0 .. N) write(f[a][b] ? '#' : '.');
    writeln;
  }
  writeln;
}
void exper3() {
  enum N = 10;
  auto f = new bool[][][](N, N, N);
  foreach (a; 0 .. N) foreach (b; 0 .. N) foreach (c; 0 .. N) {
    if (a) {
      int aa = a - 1, bb = b, cc = c;
      if (aa == 0) bb = cc = 0;
      if (!f[aa][bb][cc]) f[a][b][c] = true;
    }
    if (b) {
      int aa = a, bb = b - 1, cc = c;
      if (bb == 0) cc = 0;
      if (!f[aa][bb][cc]) f[a][b][c] = true;
    }
    if (c) {
      int aa = a, bb = b, cc = c - 1;
      if (cc == 0) {}
      if (!f[aa][bb][cc]) f[a][b][c] = true;
    }
  }
  foreach (a; 0 .. N) {
    writefln("a = %s\n", a);
    foreach (b; 0 .. N) {
      writef("%2d ", b);
      foreach (c; 0 .. N) write(f[a][b][c] ? '#' : '.');
      writeln;
    }
    writeln;
  }
  foreach (a; 1 .. N) foreach (b; 1 .. N) foreach (c; 1 .. N) {
    const brt = f[a][b][c];
    const grd = solve([a, b, c]);
    assert(brt == grd, format("%s: %s %s", [a, b, c], brt, grd));
  }
}

void main() {
  // exper2;
  // exper3;
  // return;
  
  try {
    for (; ; ) {
      const numCases = readInt;
      foreach (caseId; 0 .. numCases) {
        const N = readInt;
        auto A = new int[N];
        foreach (i; 0 .. N) A[i] = readInt;
        
        const ans = solve(A);
        writeln(ans ? "Alice" : "Bob");
      }
    }
  } catch (EOFException e) {
  }
}
0