結果
問題 | No.1501 酔歩 |
ユーザー | te-sh |
提出日時 | 2021-06-07 14:16:55 |
言語 | D (dmd 2.106.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,197 bytes |
コンパイル時間 | 1,043 ms |
コンパイル使用メモリ | 112,760 KB |
実行使用メモリ | 9,628 KB |
最終ジャッジ日時 | 2024-06-22 11:25:26 |
合計ジャッジ時間 | 5,233 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,812 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | WA | - |
testcase_05 | AC | 72 ms
7,416 KB |
testcase_06 | AC | 54 ms
6,944 KB |
testcase_07 | AC | 69 ms
7,260 KB |
testcase_08 | AC | 16 ms
6,940 KB |
testcase_09 | AC | 62 ms
8,020 KB |
testcase_10 | AC | 23 ms
6,944 KB |
testcase_11 | AC | 56 ms
6,940 KB |
testcase_12 | AC | 33 ms
6,940 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 87 ms
8,764 KB |
testcase_23 | AC | 92 ms
8,928 KB |
testcase_24 | AC | 89 ms
8,784 KB |
testcase_25 | AC | 85 ms
9,076 KB |
testcase_26 | AC | 81 ms
8,836 KB |
testcase_27 | AC | 86 ms
8,728 KB |
testcase_28 | AC | 94 ms
8,912 KB |
testcase_29 | AC | 81 ms
8,760 KB |
testcase_30 | AC | 97 ms
8,792 KB |
testcase_31 | AC | 82 ms
8,828 KB |
testcase_32 | AC | 84 ms
9,628 KB |
testcase_33 | AC | 92 ms
8,856 KB |
testcase_34 | AC | 89 ms
8,984 KB |
testcase_35 | AC | 86 ms
9,216 KB |
testcase_36 | AC | 90 ms
8,776 KB |
testcase_37 | AC | 80 ms
8,828 KB |
testcase_38 | AC | 82 ms
8,892 KB |
testcase_39 | AC | 97 ms
8,732 KB |
testcase_40 | AC | 83 ms
8,796 KB |
testcase_41 | AC | 92 ms
8,892 KB |
testcase_42 | AC | 58 ms
9,164 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 60 ms
8,700 KB |
testcase_46 | AC | 64 ms
8,804 KB |
testcase_47 | AC | 54 ms
8,760 KB |
testcase_48 | AC | 68 ms
9,048 KB |
testcase_49 | AC | 77 ms
8,988 KB |
testcase_50 | AC | 68 ms
8,928 KB |
testcase_51 | AC | 68 ms
9,072 KB |
testcase_52 | AC | 68 ms
9,444 KB |
testcase_53 | WA | - |
testcase_54 | AC | 1 ms
6,940 KB |
testcase_55 | AC | 1 ms
6,944 KB |
コンパイルメッセージ
Main.d(206): Deprecation: function `Main.IO!(makeGlobal, makeGlobal).IO.put!("{exit: true}", int).put.putMain!(c, int).putMain` function requires a dual-context, which is deprecated Main.d-mixin-176(176): instantiated from here: `putMain!(c, int)` Main.d(12): instantiated from here: `put!("{exit: true}", int)` Main.d(206): Deprecation: function `Main.IO!(makeGlobal, makeGlobal).IO.put!("{}", string).put.putMain!(c, string).putMain` function requires a dual-context, which is deprecated Main.d-mixin-176(176): instantiated from here: `putMain!(c, string)` Main.d(27): instantiated from here: `put!("{}", string)` /home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!ulong.gcdImpl`
ソースコード
// URL: https://yukicoder.me/problems/no/1501 import std.algorithm, std.array, std.bitmanip, std.container, std.conv, std.format, std.functional, std.math, std.range, std.traits, std.typecons, std.stdio, std.string; version(unittest) {} else void main() { int N, K; io.getV(N, K); long[] A; io.getA(N, A); if (K == 1) io.put!"{exit: true}"(0); auto a = new Frac!long[](N), b = new Frac!long[](N); foreach (i; 1..N-1) { a[i] = frac(A[i-1], A[i-1]+A[i+1]); b[i] = frac(A[i+1], A[i-1]+A[i+1]); } auto c = new Frac!long[](N); c[0] = frac(0L, 1L); foreach (i; 1..N-1) c[i] = b[i] / (frac(1L, 1L) - a[i] * c[i-1]); auto r = frac(1L, 1L); foreach (i; K-1..N-1) r *= c[i]; io.put(r.a.to!string ~ "/" ~ r.b.to!string); } struct Frac(T) { import std.numeric : gcd; T a, b; pure nothrow @nogc @safe { this(T a, T b) in { assert(b != 0); } do { this.a = a; this.b = b; } bool opEquals(Frac!T r) const { return (a == 0 && r.a == 0) || (a == r.a && b == r.b); } int opCmp(Frac!T r) const { return a*r.b<r.a*b ? -1 : a*r.b>r.a*b ? 1 : 0; } Frac!T inv() in { assert(a != 0); } do { return Frac!T(b, a).normalizeSign; } Frac!T opUnary(string op: "-")() { return Frac!T(-a, b); } Frac!T opBinary(string op)(Frac!T r) if (op == "+" || op == "-") { auto g = gcd(b, r.b); return Frac!T(mixin("r.b/g*a"~op~"b/g*r.a"), b/g*r.b).reduction(); } Frac!T opOpAssign(string op)(Frac!T r) if (op == "+" || op == "-") { auto g = gcd(b, r.b); a = mixin("r.b/g*a"~op~"b/g*r.a"); b = b/g*r.b; return reduction(); } Frac!T opBinary(string op: "*")(Frac!T r) { auto g1 = gcd(a.abs, r.b), g2 = gcd(r.a.abs, b); return Frac!T((a/g1)*(r.a/g2), (b/g2)*(r.b/g1)); } ref Frac!T opOpAssign(string op: "*")(Frac!T r) { auto g1 = gcd(a.abs, r.b), g2 = gcd(r.a.abs, b); a = (a/g1)*(r.a/g2); b = (b/g2)*(r.b/g1); return this; } Frac!T opBinary(string op: "/")(Frac!T r) in { assert(r.b != 0); } do { auto g1 = gcd(a.abs, r.a.abs), g2 = gcd(b, r.b); return Frac!T((a/g1)*(r.b/g2), (b/g2)*(r.a/g1)).normalizeSign(); } ref Frac!T opOpAssign(string op: "/")(Frac!T r) in { assert(r.b != 0); } do { auto g1 = gcd(a.abs, r.a.abs), g2 = gcd(b, r.b); a = (a/g1)*(r.b/g2); b = (b/g2)*(r.a/g1); return normalizeSign(); } private { ref Frac!T reduction() { auto g = gcd(a.abs, b); a /= g; b /= g; return this; } ref Frac!T normalizeSign() { if (b < 0) { a = -a; b = -b; } return this; } } } } pure nothrow @nogc @safe { Frac!T frac(T)(T a, T b) { return Frac!T(a, b).normalizeSign().reduction(); } } auto io = IO!()(); import std.stdio; struct IO(alias IN = stdin, alias OUT = stdout) { import std.meta : allSatisfy; import core.stdc.stdlib : exit; void getV(T...)(ref T v) { foreach (ref w; v) get(w); } void getA(T)(size_t n, ref T v) if (hasAssignableElements!T) { v = new T(n); foreach (ref w; v) get(w); } void getC(T...)(size_t n, ref T v) if (allSatisfy!(hasAssignableElements, T)) { foreach (ref w; v) w = new typeof(w)(n); foreach (i; 0..n) foreach (ref w; v) get(w[i]); } void getM(T)(size_t r, size_t c, ref T v) if (hasAssignableElements!T && hasAssignableElements!(ElementType!T)) { v = new T(r); foreach (ref w; v) getA(c, w); } template getS(E...) { void getS(T)(size_t n, ref T v) { v = new T(n); foreach (ref w; v) foreach (e; E) mixin("get(w."~e~");"); } } const struct PutConf { bool newline = true, flush, exit; string floatFormat = "%.10f", delimiter = " "; } void put(alias conf = "{}", T...)(T v) { mixin("const PutConf c = "~conf~"; putMain!c(v);"); } void putB(alias conf = "{}", S, T)(bool c, S t, T f) { if (c) put!conf(t); else put!conf(f); } void putRaw(T...)(T v) { OUT.write(v); OUT.writeln; } private { dchar[] buf; auto sp = (new dchar[](0)).splitter; void nextLine() { IN.readln(buf); sp = buf.splitter; } void get(T)(ref T v) { if (sp.empty) nextLine(); v = sp.front.to!T; sp.popFront(); } void putMain(PutConf c, T...)(T v) { foreach (i, w; v) { putOne!c(w); if (i+1 < v.length) OUT.write(c.delimiter); } static if (c.newline) OUT.writeln; static if (c.flush) OUT.flush(); static if (c.exit) exit(0); } void putOne(PutConf c, T)(T v) { static if (isInputRange!T && !isSomeString!T) putRange!c(v); else static if (isFloatingPoint!T) OUT.write(format(c.floatFormat, v)); else static if (hasMember!(T, "fprint")) v.fprint(OUT); else OUT.write(v); } void putRange(PutConf c, T)(T v) { auto w = v; while (!w.empty) { putOne!c(w.front); w.popFront(); if (!w.empty) OUT.write(c.delimiter); } } } }