結果
問題 | No.2355 Unhappy Back Dance |
ユーザー | mkawa2 |
提出日時 | 2023-06-16 23:07:28 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,457 ms / 6,000 ms |
コード長 | 2,591 bytes |
コンパイル時間 | 201 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 113,276 KB |
最終ジャッジ日時 | 2024-06-24 16:13:46 |
合計ジャッジ時間 | 34,573 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,444 KB |
testcase_01 | AC | 39 ms
53,476 KB |
testcase_02 | AC | 38 ms
54,348 KB |
testcase_03 | AC | 39 ms
52,872 KB |
testcase_04 | AC | 37 ms
52,624 KB |
testcase_05 | AC | 38 ms
53,208 KB |
testcase_06 | AC | 553 ms
84,200 KB |
testcase_07 | AC | 535 ms
84,024 KB |
testcase_08 | AC | 554 ms
83,940 KB |
testcase_09 | AC | 539 ms
84,000 KB |
testcase_10 | AC | 668 ms
85,788 KB |
testcase_11 | AC | 847 ms
88,108 KB |
testcase_12 | AC | 558 ms
83,892 KB |
testcase_13 | AC | 573 ms
84,248 KB |
testcase_14 | AC | 687 ms
86,108 KB |
testcase_15 | AC | 38 ms
53,412 KB |
testcase_16 | AC | 2,414 ms
112,036 KB |
testcase_17 | AC | 2,386 ms
111,976 KB |
testcase_18 | AC | 2,368 ms
112,580 KB |
testcase_19 | AC | 2,457 ms
113,276 KB |
testcase_20 | AC | 2,413 ms
111,976 KB |
testcase_21 | AC | 1,043 ms
86,040 KB |
testcase_22 | AC | 261 ms
77,320 KB |
testcase_23 | AC | 262 ms
77,348 KB |
testcase_24 | AC | 2,155 ms
106,748 KB |
testcase_25 | AC | 1,199 ms
88,360 KB |
testcase_26 | AC | 1,229 ms
88,144 KB |
testcase_27 | AC | 1,067 ms
86,112 KB |
testcase_28 | AC | 103 ms
76,372 KB |
testcase_29 | AC | 138 ms
76,744 KB |
testcase_30 | AC | 2,003 ms
104,568 KB |
testcase_31 | AC | 1,484 ms
93,732 KB |
testcase_32 | AC | 218 ms
77,068 KB |
testcase_33 | AC | 879 ms
84,244 KB |
testcase_34 | AC | 87 ms
76,572 KB |
testcase_35 | AC | 107 ms
76,292 KB |
testcase_36 | AC | 1,021 ms
85,616 KB |
testcase_37 | AC | 646 ms
80,928 KB |
testcase_38 | AC | 707 ms
82,244 KB |
testcase_39 | AC | 595 ms
80,232 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(1000005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # md = 10**9+7 md = 998244353 def arg_sort(xy): def msort(xx): if not xx: return n = len(xx) a = [xx, xx[:]] lr = [(0, n, 1, 0)] while lr: l, r, f, g = lr.pop() m = (l+r)//2 if f: lr.append((l, r, 0, g)) if m-l > 1: lr.append((l, m, 1, g ^ 1)) if r-m > 1: lr.append((m, r, 1, g ^ 1)) else: i, j, p, q = l, m, m-1, r-1 a1 = a[g] a2 = a[g ^ 1] for k in range((r-l)//2): x, y = a2[i] s, t = a2[j] if s*y-t*x > 0: a1[l+k] = a2[j] j += 1 else: a1[l+k] = a2[i] i += 1 x, y = a2[p] s, t = a2[q] if s*y-t*x > 0: a1[r-1-k] = a2[p] p -= 1 else: a1[r-1-k] = a2[q] q -= 1 if (r-l) & 1: a1[m] = a2[i] if i == p else a2[j] z1, z2, z3, z4, z5 = [], [], [], [], [] for x, y in xy: if x == y == 0: z5.append((x, y)) elif y >= 0: if x >= 0: z1.append((x, y)) else: z2.append((x, y)) else: if x < 0: z3.append((x, y)) else: z4.append((x, y)) msort(z1) msort(z2) msort(z3) msort(z4) return z1+z2+z3+z4+z5 n = II() xy = LLI(n) def ok(st): for i in range(n-2): x, y = st[i] s, t = st[i+1] if x*t-s*y == 0 and x*s >= 0 and y*t >= 0: return True return False ans = 0 for x, y in xy: st = [(s-x, t-y) for s, t in xy if s != x or t != y] st = arg_sort(st) ans += ok(st) print(ans)