結果
問題 | No.274 The Wall |
ユーザー | iehn_ |
提出日時 | 2020-08-14 10:37:08 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 310 ms / 2,000 ms |
コード長 | 2,370 bytes |
コンパイル時間 | 191 ms |
コンパイル使用メモリ | 82,572 KB |
実行使用メモリ | 93,164 KB |
最終ジャッジ日時 | 2024-06-22 02:39:13 |
合計ジャッジ時間 | 6,764 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 149 ms
90,236 KB |
testcase_01 | AC | 148 ms
89,888 KB |
testcase_02 | AC | 149 ms
89,796 KB |
testcase_03 | AC | 159 ms
90,488 KB |
testcase_04 | AC | 147 ms
90,216 KB |
testcase_05 | AC | 146 ms
89,948 KB |
testcase_06 | AC | 149 ms
90,004 KB |
testcase_07 | AC | 147 ms
90,088 KB |
testcase_08 | AC | 147 ms
89,796 KB |
testcase_09 | AC | 151 ms
90,028 KB |
testcase_10 | AC | 146 ms
89,956 KB |
testcase_11 | AC | 164 ms
90,376 KB |
testcase_12 | AC | 207 ms
90,704 KB |
testcase_13 | AC | 181 ms
90,096 KB |
testcase_14 | AC | 212 ms
91,208 KB |
testcase_15 | AC | 251 ms
92,088 KB |
testcase_16 | AC | 167 ms
90,728 KB |
testcase_17 | AC | 168 ms
90,856 KB |
testcase_18 | AC | 162 ms
90,924 KB |
testcase_19 | AC | 291 ms
92,760 KB |
testcase_20 | AC | 300 ms
93,164 KB |
testcase_21 | AC | 310 ms
92,764 KB |
testcase_22 | AC | 302 ms
92,820 KB |
testcase_23 | AC | 291 ms
92,548 KB |
testcase_24 | AC | 300 ms
92,548 KB |
testcase_25 | AC | 308 ms
92,988 KB |
ソースコード
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools import time,random sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 mod2 = 998244353 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) def pe(s): return print(str(s), file=sys.stderr) def JA(a, sep): return sep.join(map(str, a)) def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a) def scc(n, e, re): v = [None] * n t = [] def dfs(i): v[i] = 0 for b in e[i]: if v[b] is None: dfs(b) t.append(i) for i in range(n): if v[i] is None: dfs(i) r = [None] * n def dfs2(i, p): r[i] = p for b in re[i]: if r[b] is None: dfs2(b, p) for c in t[::-1]: if r[c] is None: dfs2(c, c) return r def main(): n,m = LI() lr = [LI() for _ in range(n)] e = [[] for _ in range(n*2)] re = [[] for _ in range(n*2)] def f(i,ni,li,ri,j,nj,lj,rj): if li<=lj<=ri or li<=rj<=ri or lj<=li<=rj: e[i].append(nj) re[nj].append(i) e[j].append(ni) re[ni].append(j) return 1 return 0 for i in range(n): li,ri = lr[i] rli,rri = m-ri-1,m-li-1 for j in range(i+1,n): lj,rj = lr[j] rlj,rrj = m-rj-1,m-lj-1 ac = 0 ac += f(i,i+n,li,ri,j,j+n,lj,rj) ac += f(i,i+n,li,ri,j+n,j,rlj,rrj) ac += f(i+n,i,rli,rri,j,j+n,lj,rj) ac += f(i+n,i,rli,rri,j+n,j,rlj,rrj) if ac > 3: return "NO" r = scc(n*2,e,re) for i in range(n): if r[i] == r[i+n]: return "NO" return "YES" # start = time.time() print(main()) # pe(time.time() - start)