提出 #72718316


ソースコード 拡げる

import sys
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

class Point:
  __slots__ = ('x', 'y', 'region')
  def __init__(self, x, y):
    self.x = x
    self.y = y
    if y < 0 or (y == 0 and x > 0):
      self.region = 0
    else:
      self.region = 1

  def __lt__(self, other):
    if self.region != other.region:
      return self.region < other.region

    cross = self.x * other.y - self.y * other.x
    return cross > 0

def solve():

    N, Q = map(int, input().split())

    points = []
    for i in range(N):
      X, Y = map(int, input().split())
      points.append(Point(X, Y))
    
    original_points = points[:]
    sorted_points = sorted(points)
    
    for _ in range(Q):
      A_idx, B_idx = map(int, input().split())
      p_a = original_points[A_idx - 1]
      p_b = original_points[B_idx - 1]
      idx_start = bisect_right(sorted_points, p_a) - 1
      idx_end = bisect_left(sorted_points, p_b)
      
      if idx_start < idx_end:
        count = (idx_start + 1) + (N - idx_end)
        print(count)
      else:
        count = idx_start - idx_end + 1
        print(count)

solve()

提出情報

提出日時
問題 E - Laser Takahashi
ユーザ exophia
言語 Python (PyPy 3.11-v7.3.20)
得点 450
コード長 1180 Byte
結果 AC
実行時間 1245 ms
メモリ 139156 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 450 / 450
結果
AC × 3
AC × 33
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 03_random3_04.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 05_killer_00.txt, 05_killer_01.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 54 ms 80476 KiB
00_sample_01.txt AC 53 ms 80356 KiB
00_sample_02.txt AC 53 ms 80412 KiB
01_random_00.txt AC 533 ms 116688 KiB
01_random_01.txt AC 901 ms 138172 KiB
01_random_02.txt AC 974 ms 134764 KiB
01_random_03.txt AC 144 ms 110956 KiB
01_random_04.txt AC 961 ms 138656 KiB
01_random_05.txt AC 1109 ms 138768 KiB
01_random_06.txt AC 1137 ms 138892 KiB
01_random_07.txt AC 1125 ms 138756 KiB
01_random_08.txt AC 1128 ms 138792 KiB
01_random_09.txt AC 1182 ms 138704 KiB
02_random2_00.txt AC 1186 ms 138700 KiB
02_random2_01.txt AC 1178 ms 138712 KiB
02_random2_02.txt AC 1190 ms 138676 KiB
02_random2_03.txt AC 1198 ms 138684 KiB
02_random2_04.txt AC 1234 ms 138716 KiB
02_random2_05.txt AC 1208 ms 138892 KiB
02_random2_06.txt AC 1196 ms 138696 KiB
02_random2_07.txt AC 1195 ms 138756 KiB
02_random2_08.txt AC 1227 ms 138656 KiB
02_random2_09.txt AC 1245 ms 138824 KiB
03_random3_00.txt AC 1117 ms 138812 KiB
03_random3_01.txt AC 1004 ms 139156 KiB
03_random3_02.txt AC 940 ms 139128 KiB
03_random3_03.txt AC 781 ms 139000 KiB
03_random3_04.txt AC 679 ms 139032 KiB
04_handmade_00.txt AC 309 ms 136764 KiB
04_handmade_01.txt AC 329 ms 136840 KiB
04_handmade_02.txt AC 314 ms 111016 KiB
05_killer_00.txt AC 1179 ms 138264 KiB
05_killer_01.txt AC 1214 ms 138176 KiB