結果
問題 | No.274 The Wall |
ユーザー | nebukuro09 |
提出日時 | 2016-10-20 23:46:31 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 196 ms / 2,000 ms |
コード長 | 1,085 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 77,736 KB |
実行使用メモリ | 80,896 KB |
最終ジャッジ日時 | 2023-09-04 02:13:54 |
合計ジャッジ時間 | 4,377 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
76,312 KB |
testcase_01 | AC | 73 ms
76,720 KB |
testcase_02 | AC | 75 ms
76,512 KB |
testcase_03 | AC | 96 ms
79,520 KB |
testcase_04 | AC | 74 ms
76,440 KB |
testcase_05 | AC | 73 ms
76,364 KB |
testcase_06 | AC | 73 ms
76,496 KB |
testcase_07 | AC | 74 ms
76,520 KB |
testcase_08 | AC | 73 ms
76,280 KB |
testcase_09 | AC | 74 ms
76,544 KB |
testcase_10 | AC | 72 ms
76,136 KB |
testcase_11 | AC | 97 ms
79,540 KB |
testcase_12 | AC | 137 ms
80,280 KB |
testcase_13 | AC | 87 ms
78,564 KB |
testcase_14 | AC | 116 ms
79,380 KB |
testcase_15 | AC | 146 ms
80,476 KB |
testcase_16 | AC | 97 ms
79,524 KB |
testcase_17 | AC | 98 ms
79,616 KB |
testcase_18 | AC | 96 ms
79,692 KB |
testcase_19 | AC | 175 ms
80,852 KB |
testcase_20 | AC | 185 ms
80,896 KB |
testcase_21 | AC | 185 ms
80,428 KB |
testcase_22 | AC | 174 ms
80,500 KB |
testcase_23 | AC | 179 ms
80,488 KB |
testcase_24 | AC | 188 ms
80,736 KB |
testcase_25 | AC | 196 ms
80,564 KB |
ソースコード
N, M = map(int, raw_input().split()) blocks = [map(int, raw_input().split()) for _ in xrange(N)] rinsetsu = [[] for _ in xrange(N)] for i in xrange(N): for j in xrange(i+1, N): L1, R1 = blocks[i] L2, R2 = blocks[j] L3, R3 = M-R2-1, M-L2-1 b1 = not(R2 < L1 or R1 < L2) b2 = not(R3 < L1 or R1 < L3) if b1 and b2: print 'NO' exit() elif b1 or b2: rinsetsu[i].append(j) rinsetsu[j].append(i) def dfs(start, color): color[start] = 0 stack = [start] while len(stack) > 0: node = stack.pop() next_color = (color[node]+1)%2 for next_node in rinsetsu[node]: if color[next_node] == -1: color[next_node] = next_color stack.append(next_node) elif color[next_node] != next_color: return False return color color = [-1 for _ in xrange(N)] for i in xrange(N): if color[i] == -1: color = dfs(i, color) if not color: print 'NO' exit() print 'YES'