結果

問題 No.1935 Water Simulation
ユーザー 👑 hos.lyrichos.lyric
提出日時 2022-05-13 22:12:29
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 2,132 bytes
コンパイル時間 830 ms
コンパイル使用メモリ 107,784 KB
実行使用メモリ 227,572 KB
最終ジャッジ日時 2023-09-04 17:06:49
合計ジャッジ時間 3,229 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 29 ms
40,224 KB
testcase_05 AC 116 ms
148,632 KB
testcase_06 AC 10 ms
6,136 KB
testcase_07 AC 4 ms
6,712 KB
testcase_08 AC 65 ms
98,100 KB
testcase_09 AC 103 ms
133,816 KB
testcase_10 AC 68 ms
82,568 KB
testcase_11 AC 7 ms
7,516 KB
testcase_12 AC 9 ms
12,576 KB
testcase_13 AC 4 ms
4,596 KB
testcase_14 AC 74 ms
91,956 KB
testcase_15 AC 34 ms
40,948 KB
testcase_16 AC 51 ms
54,736 KB
testcase_17 AC 25 ms
38,624 KB
testcase_18 AC 7 ms
8,264 KB
testcase_19 AC 35 ms
43,332 KB
testcase_20 AC 10 ms
9,380 KB
testcase_21 AC 69 ms
116,176 KB
testcase_22 AC 16 ms
18,716 KB
testcase_23 AC 97 ms
159,744 KB
testcase_24 AC 147 ms
227,572 KB
testcase_25 AC 5 ms
4,404 KB
testcase_26 AC 5 ms
7,448 KB
testcase_27 AC 28 ms
38,044 KB
testcase_28 AC 26 ms
20,692 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 15 ms
14,384 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; }
real readReal() { return readToken.to!real; }

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() {
  try {
    for (; ; ) {
      int[4] V;
      foreach (i; 0 .. 4) {
        V[i] = readInt;
      }
      const N = readLong;
      
      int[4][] vss;
      vss ~= [-1, -1, -1, -1];
      auto app = new int[][][][](V[0] + 1, V[1] + 1, V[2] + 1, V[3] + 1);
      int[4] vs;
      vs[0] = V[0];
      foreach (i; 1 .. N + 1) {
        const j = app[vs[0]][vs[1]][vs[2]][vs[3]];
        if (j) {
          vs = vss[cast(int)(j + ((N + 1) - j) % (i - j))];
          break;
        }
        vss ~= vs;
        app[vs[0]][vs[1]][vs[2]][vs[3]] = cast(int)(i);
        auto ws = vs;
        const j0 = cast(int)((i - 1) & 3);
        const j1 = cast(int)(i & 3);
        ws[j1] = min(vs[j0] + vs[j1], V[j1]);
        ws[j0] = vs[j0] + vs[j1] - ws[j1];
        vs = ws;
        debug {
          writeln(i, " ", vs);
        }
      }
      
      writeln(vs[0], " ", vs[1], " ", vs[2], " ", vs[3]);
break;
    }
  } catch (EOFException e) {
  }
}
0