結果

問題 No.274 The Wall
ユーザー te-sh
提出日時 2017-06-05 17:25:08
言語 D
(dmd 2.109.1)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 595 bytes
コンパイル時間 758 ms
コンパイル使用メモリ 101,760 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-12 19:44:50
合計ジャッジ時間 3,338 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto rd1 = readln.split.to!(size_t[]), n = rd1[0], m = rd1[1];

  auto g = new bool[][](n, m);
  foreach (i; 0..n) {
    auto rd2 = readln.split.to!(size_t[]), l = rd2[0], r = rd2[1] + 1;
    foreach (j; l..r) g[i][j] = true;
  }

  auto ci = new int[](m);
  foreach (i; 0..m)
    ci[i] = g.transversal(i).count!"a".to!int;

  if (m % 2 && ci[m/2+1] >= 2) {
    writeln("NO");
    return;
  }

  foreach (i; 0..m/2)
    if (ci[i] + ci[$-i-1] >= 3) {
      writeln("NO");
      return;
    }

  writeln("YES");
}
0