結果
問題 | No.2702 Nand Nor Matrix |
ユーザー | 👑 hos.lyric |
提出日時 | 2024-03-30 00:58:40 |
言語 | D (dmd 2.106.1) |
結果 |
AC
|
実行時間 | 350 ms / 2,000 ms |
コード長 | 3,169 bytes |
コンパイル時間 | 961 ms |
コンパイル使用メモリ | 119,428 KB |
実行使用メモリ | 22,520 KB |
最終ジャッジ日時 | 2024-09-30 17:19:50 |
合計ジャッジ時間 | 16,662 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 177 ms
6,820 KB |
testcase_02 | AC | 176 ms
6,820 KB |
testcase_03 | AC | 177 ms
6,820 KB |
testcase_04 | AC | 184 ms
6,932 KB |
testcase_05 | AC | 180 ms
7,324 KB |
testcase_06 | AC | 177 ms
6,816 KB |
testcase_07 | AC | 180 ms
6,820 KB |
testcase_08 | AC | 178 ms
6,820 KB |
testcase_09 | AC | 178 ms
6,816 KB |
testcase_10 | AC | 181 ms
6,816 KB |
testcase_11 | AC | 181 ms
6,824 KB |
testcase_12 | AC | 180 ms
6,940 KB |
testcase_13 | AC | 178 ms
6,816 KB |
testcase_14 | AC | 179 ms
6,816 KB |
testcase_15 | AC | 177 ms
6,816 KB |
testcase_16 | AC | 220 ms
13,852 KB |
testcase_17 | AC | 123 ms
12,252 KB |
testcase_18 | AC | 166 ms
7,412 KB |
testcase_19 | AC | 259 ms
7,104 KB |
testcase_20 | AC | 114 ms
7,228 KB |
testcase_21 | AC | 131 ms
14,008 KB |
testcase_22 | AC | 96 ms
6,816 KB |
testcase_23 | AC | 229 ms
13,964 KB |
testcase_24 | AC | 231 ms
22,248 KB |
testcase_25 | AC | 109 ms
6,816 KB |
testcase_26 | AC | 147 ms
13,272 KB |
testcase_27 | AC | 300 ms
7,604 KB |
testcase_28 | AC | 225 ms
13,892 KB |
testcase_29 | AC | 50 ms
6,820 KB |
testcase_30 | AC | 301 ms
22,520 KB |
testcase_31 | AC | 220 ms
13,916 KB |
testcase_32 | AC | 30 ms
6,820 KB |
testcase_33 | AC | 94 ms
7,136 KB |
testcase_34 | AC | 227 ms
13,968 KB |
testcase_35 | AC | 251 ms
14,268 KB |
testcase_36 | AC | 350 ms
21,860 KB |
testcase_37 | AC | 337 ms
21,176 KB |
testcase_38 | AC | 335 ms
22,460 KB |
testcase_39 | AC | 345 ms
21,368 KB |
testcase_40 | AC | 334 ms
11,640 KB |
testcase_41 | AC | 336 ms
21,328 KB |
testcase_42 | AC | 336 ms
21,312 KB |
testcase_43 | AC | 338 ms
22,260 KB |
testcase_44 | AC | 340 ms
21,628 KB |
testcase_45 | AC | 343 ms
21,752 KB |
testcase_46 | AC | 336 ms
21,272 KB |
testcase_47 | AC | 339 ms
22,080 KB |
testcase_48 | AC | 336 ms
21,824 KB |
testcase_49 | AC | 335 ms
21,308 KB |
testcase_50 | AC | 336 ms
21,660 KB |
testcase_51 | AC | 215 ms
6,820 KB |
ソースコード
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() { try { for (; ; ) { const N = readInt; auto A = new int[N]; auto B = new int[N]; foreach (y; 0 .. N) A[y] = readInt; foreach (x; 1 .. N) B[x] = readInt; B[0] = A[0]; const Q = readInt; auto T = new long[Q]; auto X = new int[Q]; auto Y = new int[Q]; foreach (q; 0 .. Q) { T[q] = readLong; X[q] = readInt - 1; Y[q] = readInt - 1; } int m, n; if (A[1] == B[1]) { for (n = 1; n < N && ((A[n] - A[1]) & 1) == ((n - 1) & 1); ++n) {} for (m = 1; m < N && ((B[m] - B[1]) & 1) == ((m - 1) & 1); ++m) {} } debug { writefln("m = %s, n = %s", m, n); } int solve(long t, int x, int y) { if (x == 0) return A[y]; if (y == 0) return B[x]; int ret; if (x < m && y < n && x + y <= t + A[1]) { ret = (x + y + t + A[1] + 1) & 1; } ret ^= (t & 1); return ret; } debug { const limT = 2 * N + 5; auto brt = new int[][][](limT, N, N); foreach (y; 0 .. N) brt[0][0][y] = A[y]; foreach (x; 1 .. N) brt[0][x][0] = B[x]; foreach (t; 0 .. limT - 1) { foreach (x; 0 .. N) foreach (y; 0 .. N) { brt[t + 1][x][y] = (x == 0 || y == 0) ? brt[t][x][y] : ((brt[t][x - 1][y] + brt[t][x][y - 1] + brt[t][x][y] <= 1) ? 1 : 0); } } foreach (t; 0 .. limT) { writeln("t = ", t); foreach (x; 0 .. N) { foreach (y; 0 .. N) write(brt[t][x][y] ^ (t & 1)); writeln; } foreach (x; 0 .. N) foreach (y; 0 .. N) { const slv = solve(t, x, y); assert(brt[t][x][y] == slv, format("%s %s %s: %s %s", t, x, y, brt[t][x][y], slv)); } } } foreach (q; 0 .. Q) { writeln(solve(T[q], X[q], Y[q])); } } } catch (EOFException e) { } }