- 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
- 45 lines of Python from the credited upstream file abc266_c.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 3 4def is_inside(ax, ay, bx, by, cx, cy, tx, ty):5 abXat = (bx - ax) * (ty - ay) - (by - ay) * (tx - ax)6 bcXbt = (cx - bx) * (ty - by) - (cy - by) * (tx - bx)7 caXct = (ax - cx) * (ty - cy) - (ay - cy) * (tx - cx)8 9 if (abXat > 0.0 and bcXbt > 0.0 and caXct > 0.0) or ( abXat < 0.0 and bcXbt < 0.0 and caXct < 0.0):10 return True11 elif (abXat * bcXbt * caXct == 0.0):12 return False13 14 return False15 16 17def is_concave(px, py):18 for i in range(4):19 if is_inside(px[i % 4], py[i % 4], px[(i + 1) % 4], py[(i + 1) % 4], px[(i + 2) % 4], py[(i + 2) % 4], px[(i + 3) % 4], py[(i + 3) % 4]):20 return True21 22 return False23 24 25def main():26 import sys27 28 input = sys.stdin.readline29 30 px = [0] * 431 py = [0] * 432 33 for i in range(4):34 xi, yi = map(int, input().split())35 px[i], py[i] = xi, yi36 37 if is_concave(px, py):38 print("No")39 else:40 print("Yes")41 42 43if __name__ == "__main__":44 main()45