2257 Booking Seats
时间限制 : 2000/1000 MS(Java/Others) | 内存限制 : 131072/65536 KB(Java/Others)
提交数 : 9 | 通过数 : 3
题目描述
John and Brus are going to a theater to see a very interesting movie. They would like to have seats next to each other in the same row. The theater contains n rows, with m seats in each row. Rows are numbered 1 to n from front to back, and seats are numbered 1 to m from left to right. Some of the seats are already reserved, but John and Brus can book any of the available seats. You are given one line with rows and one line with seats. The i-th elements of row and seat are the row number and seat number of the i-th reserved seat. All remaining seats are available. Return the number of ways for John and Brus to book two available seats next to each other in the same row.
Notes
-
Two bookings are considered different only if one contains a seat that the other does not contain. In other words, they don't need to decide which seat John sits in and which seat Brus sits in.
Constraints
-
n and m will each be between 1 and 50, inclusive.
-
row will contain between 1 and 50 elements, inclusive.
-
row and seat will contain the same number of elements.
-
Each element of row will be between 1 and n, inclusive.
-
Each element of seat will be between 1 and m, inclusive.
-
All pairs (row[i], seat[i]) will be distinct.
输入要求
In the first line there wiil be threee numbers n,m and l,meanings that
thert are n rows and m seats per row,and l seats are reserved;
And then two lines,one line l numbers meanings row number, one line l numbers meanings seat number;
输出要求
Output the number of ways for John and Brus to book two available seats next to each other in the same row.
输入样例
2
3
2
1 2
2 3
2
3
6
1 1 1 2 2 2
1 2 3 1 2 3
4
7
1
1
1
10
8
10
1 9 6 10 6 7 9 3 9 2
7 7 3 3 7 1 5 1 6 2
输出样例
1
0
23
54
提示
来源
TopCoder
[ 返回顶端 ] | [ 代码提交 ] | [ 统计数据 ] | [ 历史提交 ]