Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
MCONVOI - Con Voi |
English | Vietnamese |
An elephant lives by a lake with N plants on the surface. The lake can be modeled by a coordinate plane, with plants at points with integer coordinates. Every morning after waking up, the elephant performs his morning exercise, happily jumping from plant to plant. For reasons best left undiscussed, the elephant can always jump only to another plant with both coordinates larger than the coordinates of the plant it is currently on. In other words, from plant (x1, y1) the elephant can jump to plant (x2, y2) only if x2 > x1 and y2 > y1. The elephant can start his exercise at any plant on the lake. Write a program that, given the coordinates of all plants, calculates the length of the longest sequence of plants the elephant can visit. Additionally, calculate the number of different such longest sequences. Because this second number can be large, calculate it modulo 1 000 000 007.
Input
The first line contains the integer N (1 ≤ N ≤ 300 000), the number of plants. Each of the following N lines contains the coordinates of one plant, two integers between 0 and 10^9. No two plants will have the same pair of coordinates.
Output
On the first line output the length of the longest sequence of plants the elephant can jump on. On the second line output the number of such sequences of maximum length, modulo 1 000 000 007.
Sample
input
11
8 6
7 4
5 4
5 1
5 6
6 2
3 2
4 3
4 5
3 5
2 4
output
4
3
input
6
1 3
2 2
3 1
5 3
4 4
3 5
output
2
7
Được gửi lên bởi: | psetter |
Ngày: | 2009-03-02 |
Thời gian chạy: | 1s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET |
Nguồn bài: | COI 08 |
hide comments
|
||||||
2019-11-05 15:38:43
dijkstra ac |
||||||
2018-11-16 04:15:50
mod nho xu li so am |
||||||
2018-08-11 17:50:31
IT ac :D http://bit.ly/2FnjkEm sạch ko tỳ vết :v Last edit: 2019-01-11 17:38:02 |
||||||
2018-01-12 08:48:29
kho vai noi ra Last edit: 2018-01-12 08:49:27 |
||||||
2018-01-01 02:13:43
1/1/2018 VOI ledacthuongvq |
||||||
2017-12-31 10:10:47 hồ vãn tuấn
1 0 0 thi sao |
||||||
2017-06-21 04:36:39
đéo ns nhiều 1 đấm ac :) cơ mà nghĩ lâu vãi |
||||||
2017-06-18 03:53:27
Bài này LIS cơ bản thôi có gì mà IT 2D :) |
||||||
2016-08-26 18:10:09 Sơn Tùng M-TP
BIT 2D đồ đủ kiểu. Đúng là làm quá mà... :)) |
||||||
2016-06-15 04:11:16
Duyet trau la AC lien =)) |