D. [USACO08NOV] Mixed Up Cows G

    Type: RemoteJudge 1000ms 125MiB

[USACO08NOV] Mixed Up Cows G

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

Each of Farmer John's NN (4≤N≤164 \le N \le 16) cows has a unique serial number SiS_i (1≤Si≤250001 \le S_i \le 25000). The cows are so proud of it that each one now wears her number in a gangsta manner engraved in large letters on a gold plate hung around her ample bovine neck.

Gangsta cows are rebellious and line up to be milked in an order called 'Mixed Up'. A cow order is 'Mixed Up' if the sequence of serial numbers formed by their milking line is such that the serial numbers of every pair of consecutive cows in line differs by more than KK (1≤K≤34001 \le K \le 3400). For example, if N=6N = 6 and K=1K = 1 then 1,3,5,2,6,41, 3, 5, 2, 6, 4 is a 'Mixed Up' lineup but 1,3,6,5,2,41, 3, 6, 5, 2, 4 is not (since the consecutive numbers 55 and 66 differ by 11).

How many different ways can NN cows be Mixed Up?

For your first 1010 submissions, you will be provided with the results of running your program on a part of the actual test data.

POINTS: 200200.

输入格式

Line 11: Two space-separated integers: NN and KK.

Lines 2…N+12 \dots N+1: Line i+1i+1 contains a single integer that is the serial number of cow ii : SiS_i.

输出格式

Line 11: A single integer that is the number of ways that NN cows can be 'Mixed Up'. The answer is guaranteed to fit in a 64 bit integer.

4 1 
3 
4 
2 
1 

2 

提示

The 22 possible Mixed Up arrangements are:

  • 3,1,4,23,1,4,2

  • 2,4,1,32,4,1,3

初一竞赛组作业——状压DP2

Not Claimed
Status
Done
Problem
5
Open Since
2025-5-9 9:30
Deadline
2025-6-7 23:59
Extension
24 hour(s)