結果
問題 | No.3137 Non-Intersect Chord Triangle Game |
ユーザー |
👑 |
提出日時 | 2025-05-03 11:05:29 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 137 ms / 2,000 ms |
コード長 | 2,541 bytes |
コンパイル時間 | 939 ms |
コンパイル使用メモリ | 102,316 KB |
実行使用メモリ | 17,904 KB |
最終ジャッジ日時 | 2025-05-03 11:05:36 |
合計ジャッジ時間 | 6,405 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 65 |
ソースコード
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)); } void main() { debug {{ enum L = 100; auto dp = new int[L]; foreach (n; 0 .. L) { // Red: 0, i foreach (i; 1 .. n) { int mn = 1; // Blue: j foreach (j; 1 .. i) chmin(mn, dp[j - 0 - 1] | dp[i - j - 1] | dp[n - i - 1]); foreach (j; i + 1 .. n) chmin(mn, dp[i - 0 - 1] | dp[j - i - 1] | dp[n - j - 1]); chmax(dp[n], mn); } } writeln(dp); foreach (n; 0 .. L) assert(dp[n] == ((n % 4 == 2) ? 1 : 0)); }} try { for (; ; ) { const N = readInt; const M = readInt; auto P = new int[M]; auto Q = new int[M]; foreach (i; 0 .. M) { P[i] = readInt - 1; Q[i] = readInt - 1; if (P[i] > Q[i]) swap(P[i], Q[i]); } auto fs = new int[N]; foreach (i; 0 .. M) { fs[P[i]] = +1; fs[Q[i]] = -1; } int top; auto stack = new int[N + 1]; int[] ns; foreach (x; 0 .. N) { if (fs[x] > 0) { stack[++top] = 0; } else if (fs[x] < 0) { ns ~= stack[top--]; } else { ++stack[top]; } } ns ~= stack[0]; debug writeln("ns = ", ns); bool ans; foreach (n; ns) ans = ans || (n % 4 == 2); writeln(ans ? "Akane" : "Aoi"); } } catch (EOFException e) { } }