結果

問題 No.3262 水色コーダーさん、その問題d問題ですよ?(1<=d<=N)
ユーザー kmmtkm
提出日時 2025-09-06 13:27:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 82,244 KB
実行使用メモリ 76,316 KB
最終ジャッジ日時 2025-09-06 13:27:47
合計ジャッジ時間 2,817 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

# 自作ライブラリ
# https://github.com/takumi-okamoto/competitive-programming-public/tree/main/mylib

import sys
from itertools import permutations


# sys.setrecursionlimit(10**8)


def debug(*args):
    print(*args, file=sys.stderr)


def main():
    n = int(input())
    lr = [list(map(int, input().split())) for _ in range(n)]
    ans = 0
    for p in permutations(range(n)):
        x = lr[p[0]][0]
        flg = 1
        for i in range(1, n):
            l, r = lr[p[i]]
            if x < l:
                x = l
            elif l <= x <= r:
                continue
            else:
                flg = 0
        ans += flg

    print(ans)


if __name__ == "__main__":
    main()
0