목차

My뷰 꾸미기

ps
링크acmicpc.net/…
출처BOJ
문제 번호25556
문제명My뷰 꾸미기
레벨플래티넘 4
분류

조합론

시간복잡도O(n)
인풋사이즈n<=300,000
사용한 언어Python 3.13
제출기록84244KB / 716ms
최고기록700ms
해결날짜2026/01/28

풀이

코드

"""Solution code for "BOJ 25569. My뷰 꾸미기".

- Problem link: https://www.acmicpc.net/problem/25569
- Solution link: http://www.teferi.net/ps/problems/boj/25569

Tags: [combinatorics]
"""

import sys
from teflib import combinatorics

MOD = 10**9 + 7


def main():
    N = int(sys.stdin.readline())

    answer = 1
    cc = combinatorics.CombCalculator(MOD)
    for _ in range(N):
        A, B = [int(x) for x in sys.stdin.readline().split()]
        large, small = (A, B) if A > B else (B, A)
        answer = answer * (cc.comb(large + small, small) - 1) % MOD

    print(answer)


if __name__ == '__main__':
    main()