結果

問題 No.1703 Much Matching
ユーザー tassei903tassei903
提出日時 2021-10-08 23:12:54
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,827 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 146,596 KB
最終ジャッジ日時 2023-09-30 12:57:16
合計ジャッジ時間 11,361 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,592 KB
testcase_01 AC 75 ms
71,256 KB
testcase_02 AC 74 ms
71,248 KB
testcase_03 AC 76 ms
71,588 KB
testcase_04 AC 89 ms
75,996 KB
testcase_05 AC 82 ms
75,896 KB
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 AC 382 ms
94,952 KB
testcase_10 WA -
testcase_11 AC 177 ms
79,688 KB
testcase_12 WA -
testcase_13 AC 220 ms
82,220 KB
testcase_14 WA -
testcase_15 AC 173 ms
79,024 KB
testcase_16 WA -
testcase_17 AC 287 ms
87,416 KB
testcase_18 WA -
testcase_19 AC 492 ms
104,376 KB
testcase_20 WA -
testcase_21 AC 564 ms
108,588 KB
testcase_22 WA -
testcase_23 AC 243 ms
83,212 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 301 ms
88,212 KB
testcase_28 AC 487 ms
100,708 KB
testcase_29 AC 187 ms
79,604 KB
testcase_30 WA -
testcase_31 RE -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 RE -
testcase_36 AC 1,028 ms
146,596 KB
testcase_37 AC 97 ms
76,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

class SegmentTree:
    # 初期化処理
    # f : SegmentTreeにのせるモノイド
    # default : fに対する単位元
    def __init__(self, size, f=lambda x,y : x+y, default=0):
        self.size = 2**(size-1).bit_length() # 簡単のため要素数Nを2冪にする
        self.default = default
        self.dat = [default]*(self.size*2) # 要素を単位元で初期化
        self.f = f

    def update(self, i, x):
        i += self.size
        self.dat[i] = max(self.dat[i], x)
        while i > 0:
            i >>= 1
            self.dat[i] = self.f(self.dat[i*2], self.dat[i*2+1])

    def query(self, l, r):
        l += self.size
        r += self.size
        lres, rres = self.default, self.default
        while l < r:
            if l & 1:
                lres = self.f(lres, self.dat[l])
                l += 1

            if r & 1:
                r -= 1
                rres = self.f(self.dat[r], rres) # モノイドでは可換律は保証されていないので演算の方向に注意
            l >>= 1
            r >>= 1
        res = self.f(lres, rres)
        return res


n,m,q = na()
g = [[] for i in range(n+1)]
for i in range(q):
    a,b = na()
    g[a].append(b)


st = SegmentTree(m+1, max, default = 0)
for i in range(1,n+1):
    c = []
    for j in g[i]:
        c.append(st.query(0, j))

    for t, j in enumerate(g[i]):
        st.update(j, c[t]+1)
    #print(st.dat)
print(st.query(0, n+1))
0