結果

問題 No.1003 サイコロの実装 (1)
ユーザー te-sh
提出日時 2020-03-27 01:52:51
言語 D
(dmd 2.091.0)
結果
AC  
実行時間 2 ms
コード長 2,615 Byte
コンパイル時間 640 ms
使用メモリ 8,948 KB
最終ジャッジ日時 2020-03-27 01:52:54

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
0_sample1.txt AC 1 ms
6,896 KB
0_sample2.txt AC 2 ms
6,896 KB
0_sample3.txt AC 1 ms
6,900 KB
1_test1.txt AC 2 ms
6,900 KB
1_test2.txt AC 1 ms
6,900 KB
1_test3.txt AC 1 ms
8,944 KB
1_test4.txt AC 2 ms
8,940 KB
1_test5.txt AC 2 ms
8,940 KB
1_test6.txt AC 1 ms
6,900 KB
1_test7.txt AC 1 ms
8,948 KB
1_test8.txt AC 1 ms
8,940 KB
1_test9.txt AC 2 ms
6,900 KB
1_test10.txt AC 2 ms
6,900 KB
1_test11.txt AC 2 ms
6,896 KB
1_test12.txt AC 1 ms
6,900 KB
1_test13.txt AC 1 ms
8,944 KB
2_test1.txt AC 1 ms
6,900 KB
2_test2.txt AC 2 ms
6,896 KB
2_test3.txt AC 2 ms
8,940 KB
2_test4.txt AC 1 ms
6,900 KB
2_test5.txt AC 1 ms
8,948 KB
2_test6.txt AC 1 ms
6,896 KB
2_test7.txt AC 1 ms
8,896 KB
2_test8.txt AC 1 ms
8,944 KB
2_test9.txt AC 1 ms
8,940 KB
2_test10.txt AC 1 ms
8,900 KB
largest AC 1 ms
8,896 KB
smallest AC 1 ms
6,900 KB
テストケース一括ダウンロード

ソースコード

diff #
// URL: https://yukicoder.me/problems/no/1003

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()
{
  long N; io.getV(N);
  io.putB(N%6 == 0, "Yes", "No");
}

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