結果
問題 | No.1864 Shortest Paths Counting |
ユーザー |
![]() |
提出日時 | 2022-03-04 22:55:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,842 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 82,544 KB |
実行使用メモリ | 182,832 KB |
最終ジャッジ日時 | 2024-07-18 21:31:10 |
合計ジャッジ時間 | 16,438 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 16 |
ソースコード
mod = 998244353eps = 10**-9def main():import sysinput = sys.stdin.buffer.readlineclass Bit:def __init__(self, n):self.size = nself.tree = [0] * (n + 1)def sum(self, i):s = 0while i > 0:s += self.tree[i]i -= i & -ireturn sdef add(self, i, x):while i <= self.size:self.tree[i] += xself.tree[i] %= modi += i & -idef lower_bound(self, w):if w <= 0:return 0x = 0k = 1 << (self.size.bit_length() - 1)while k:if x + k <= self.size and self.tree[x + k] < w:w -= self.tree[x + k]x += kk >>= 1return x + 1N = int(input())XY_ori = []XY = []for _ in range(N):x, y = map(int, input().split())XY_ori.append((x, y))XY.append((x + y, x - y))if XY[0][0] > XY[-1][0]:XY = [(-x, y) for x, y in XY]if XY[0][1] > XY[-1][1]:XY = [(x, -y) for x, y in XY]XYI = []Y = set()for i, xy in enumerate(XY):x, y = xyXYI.append((x, y, i))Y.add(y)XYI.sort(key=lambda z: z[1])XYI.sort(key=lambda z: z[0])idx = {y: i + 1 for i, y in enumerate(sorted(list(Y)))}L = len(idx)bit = Bit(L)flg = 1for x, y, i in XYI:if flg:if i != 0:continueelse:flg = 0bit.add(idx[y], 1)continuej = idx[y]a = bit.sum(j)if i == N - 1:print(a)breakbit.add(j, a)if __name__ == '__main__':main()