- Translate each rule into one explicit state update.
- Maintain the invariant after every processed item.
- Return the accumulated state once all relevant input has been handled.
Code notes
- 57 lines of Python from the credited upstream file abc460_b.py.
- The implementation visibly relies on ordered lookup.
- No explicit loop blocks detected.
Complexity
Count the number and nesting of passes over the input, then include the maintained containers in the memory estimate.
Check the problem constraints before deciding whether this complexity will pass.
Use this to learn the idea, then write your own version.
12 3from enum import Enum, auto4 5 678class TwoCirclesPosition(Enum):9 Inside = auto()10 Inscribed = auto()11 Intersect = auto()12 Circumscribed = auto()13 Outside = auto()14 15 16def is_intersected(xi: int, yi: int, ri: int, xj: int, yj: int, rj: int):17 dist = abs(xi - xj) ** 2 + abs(yi - yj) ** 218 19 if rj > ri:20 ri, rj = rj, ri21 22 if (ri - rj) ** 2 > dist:23 return TwoCirclesPosition.Inside24 if (ri - rj) ** 2 == dist:25 return TwoCirclesPosition.Inscribed26 elif (ri - rj) ** 2 < dist < (ri + rj) ** 2:27 return TwoCirclesPosition.Intersect28 elif dist == (ri + rj) ** 2:29 return TwoCirclesPosition.Circumscribed30 elif dist > (ri + rj) ** 2:31 return TwoCirclesPosition.Outside32 33 34def solve():35 x1, y1, r1, x2, y2, r2 = map(int, input().split())36 results = is_intersected(x1, y1, r1, x2, y2, r2)37 38 if results in [TwoCirclesPosition.Inside, TwoCirclesPosition.Outside]:39 print("No")40 else:41 print("Yes")42 43 44def main():45 import sys46 47 input = sys.stdin.readline48 49 t = int(input())50 51 for _ in range(t):52 solve()53 54 55if __name__ == "__main__":56 main()57