結果

問題 No.923 オセロきりきざむたん
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-11-08 22:09:17
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 3,223 bytes
コンパイル時間 879 ms
コンパイル使用メモリ 109,412 KB
実行使用メモリ 13,604 KB
最終ジャッジ日時 2023-09-04 03:18:28
合計ジャッジ時間 5,205 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 4 ms
4,376 KB
testcase_27 AC 3 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 1 ms
4,376 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 2 ms
4,380 KB
testcase_41 AC 1 ms
4,376 KB
testcase_42 AC 1 ms
4,376 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 1 ms
4,380 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 1 ms
4,384 KB
testcase_47 AC 2 ms
4,380 KB
testcase_48 AC 2 ms
4,376 KB
testcase_49 AC 2 ms
4,380 KB
testcase_50 AC 10 ms
4,376 KB
testcase_51 AC 10 ms
4,376 KB
testcase_52 AC 9 ms
4,376 KB
testcase_53 AC 30 ms
10,096 KB
testcase_54 AC 12 ms
4,380 KB
testcase_55 AC 13 ms
4,376 KB
testcase_56 AC 13 ms
4,380 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 1 ms
4,376 KB
testcase_59 AC 1 ms
4,376 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 1 ms
4,380 KB
testcase_62 AC 2 ms
4,380 KB
testcase_63 AC 2 ms
4,380 KB
testcase_64 AC 2 ms
4,376 KB
testcase_65 AC 58 ms
13,604 KB
testcase_66 AC 57 ms
12,636 KB
testcase_67 AC 56 ms
12,652 KB
testcase_68 AC 55 ms
12,636 KB
testcase_69 AC 4 ms
4,380 KB
testcase_70 AC 3 ms
4,380 KB
testcase_71 AC 56 ms
12,664 KB
testcase_72 AC 4 ms
4,380 KB
testcase_73 AC 2 ms
4,380 KB
testcase_74 AC 2 ms
4,380 KB
testcase_75 AC 3 ms
4,380 KB
testcase_76 AC 2 ms
4,376 KB
testcase_77 AC 3 ms
4,380 KB
testcase_78 AC 1 ms
4,380 KB
testcase_79 AC 3 ms
4,380 KB
testcase_80 AC 4 ms
4,376 KB
testcase_81 AC 3 ms
4,380 KB
testcase_82 AC 5 ms
4,380 KB
testcase_83 AC 3 ms
4,376 KB
testcase_84 AC 4 ms
4,380 KB
testcase_85 AC 2 ms
4,380 KB
testcase_86 AC 3 ms
4,380 KB
testcase_87 AC 4 ms
4,376 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.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() {
  debug {
    foreach (m; 1 .. 4) foreach (n; 1 .. 5) {
      foreach (p; 0 .. 1 << (m * n)) {
        auto a = new int[][](m, n);
        foreach (x; 0 .. m) foreach (y; 0 .. n) {
          a[x][y] = (p >> (x * n + y)) & 1;
        }
        auto dp = new bool[][][][][](m + 1, m + 1, n + 1, n + 1, 2);
        foreach (x; 0 .. m) foreach (y; 0 .. n) {
          dp[x][x + 1][y][y + 1][a[x][y]] = true;
        }
        foreach (h; 1 .. m + 1) foreach (w; 1 .. n + 1) {
          foreach (x0; 0 .. m - h + 1) foreach (y0; 0 .. n - w + 1) {
            const x1 = x0 + h, y1 = y0 + w;
            foreach (x; x0 + 1 .. x1) {
              foreach (s; 0 .. 2) {
                if (dp[x0][x][y0][y1][s] && dp[x][x1][y0][y1][s ^ 1]) {
                  dp[x0][x1][y0][y1][] = true;
                }
              }
            }
            foreach (y; y0 + 1 .. y1) {
              foreach (s; 0 .. 2) {
                if (dp[x0][x1][y0][y][s] && dp[x0][x1][y][y1][s ^ 1]) {
                  dp[x0][x1][y0][y1][] = true;
                }
              }
            }
          }
        }
        /*
        foreach (x; 0 .. m) {
          foreach (y; 0 .. n) {
            write(a[x][y]);
          }
          writeln();
        }
        writeln(dp[0][m][0][n][1]);
        writeln();
        */
        
        const row = iota(m).any!(x => iota(n).all!(y => (a[x][0] == a[x][y])));
        const col = iota(n).any!(y => iota(m).all!(x => (a[0][y] == a[x][y])));
        if (m * n > 1) {
          assert(dp[0][m][0][n][1] == !(row && col));
        }
      }
    }
  }
  
  try {
    for (; ; ) {
      const M = readInt();
      const N = readInt();
      auto A = new string[M];
      foreach (x; 0 .. M) {
        A[x] = readToken();
      }
      
      const row = iota(M).any!(x => iota(N).all!(y => (A[x][0] == A[x][y])));
      const col = iota(N).any!(y => iota(M).all!(x => (A[0][y] == A[x][y])));
      const ans = ((M == 1 && N == 1) || !(row && col));
      writeln(ans ? "YES" : "NO");
    }
  } catch (EOFException e) {
  }
}
0