結果

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

ソースコード

diff #

from itertools import permutations

N = int(input())
xs = []
for _ in range(N):
    L, R = map(int, input().split())
    xs.append((L, R))


def is_valid(ps):
    p = xs[ps[0]][0]
    for i in range(1, N):
        l, r = xs[ps[i]]
        if p > r: return False
        p = max(p, l)

    return True


ans = 0
for ps in permutations(range(N)):
    if is_valid(ps):
        ans += 1

print(ans)
0