Skip to content

Commit 160cee3

Browse files
committed
Upload Lab8 Problems
1 parent 2620bad commit 160cee3

File tree

4 files changed

+152
-0
lines changed

4 files changed

+152
-0
lines changed

Lab8/A/Readme.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Closest
2+
3+
#### Description
4+
5+
Given $n$ points on a two-dimensional plane, please find the closest pairs of points.
6+
7+
#### Input Format
8+
9+
The first line includes one integer $n$, which is the number of points.
10+
11+
The next $n$ lines, each containing two integers $x_i$, $y_i$, represent the coordinates of the $i$-th point.
12+
13+
#### Output Format
14+
15+
Output a line containing an integer $D^2$ that represents the **square** of the distance between the two closest points.
16+
17+
#### Sample
18+
19+
##### Input
20+
21+
```mathematica
22+
5
23+
1 1
24+
1 9
25+
9 1
26+
9 9
27+
0 10
28+
```
29+
30+
##### Output
31+
32+
```mathematica
33+
2
34+
```
35+
36+
#### Range:
37+
38+
For 40% testcases: $1≤n≤3000$
39+
40+
For all testcases: $1≤n≤10^5,|x_i|, |y_i|≤2×10^7$

Lab8/B/Readme.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Urban Construction
2+
3+
### Description
4+
5+
**Sjkmost** persuaded **Justin** to force his citizens to trip with zipline. However, the citizens are not strong enough and the citizens often fell from the zipline. Therefore, they decided to provide the citizens with some cable cars. Now **Sjkmost** is preparing the cable cars.
6+
7+
There are $n$ cable cars on the cable, each has an index $a_i$. **Sjkmost** is trying to put them in order.
8+
9+
**Sjkmost** can spend $c$ *justin* (a type of currency) to cut down a segment of rope of length $c$, rotate it and splice back. That is, he can spend $r−l+1$ *justin* to rotate the cable cars in an interval.
10+
11+
**Sjkmost** has a budget of $2×10^7$ *justin*. He should sort the cable cars with some operations with a total cost no more than $2×10^7$ *justin*. But he is so good at sorting that this problem is too boring for him.
12+
13+
**lhyyy**, who is not good at graph theory at all and got lost in **Justin**'s city, luckily met **Justin** at last. Now he doesn't know how to leave the city. If he can help sort the cable cars for **Sjkmost**, **Sjkmost** will tell him how to leave. However, **lhyyy** is not good at sorting as well. Can you help him?
14+
15+
### Input Format
16+
17+
The first line contains an integer $n (1≤n≤10^5)$, indicating the number of cable cars.
18+
19+
The second line contains $n$ integers $a_1,a_2,...,a_n (1≤a_i≤10^9)$, indicating the indexes of the cable cars.
20+
21+
### Output Format
22+
23+
Output the operations in order.
24+
25+
Each line contains two integers $l_i,r_i$ satisfying $1≤l_i≤r_i≤n$, which means rotating the interval $[l_i,r_i]$.
26+
27+
Finally, output a line `-1 -1` denoting the end of the output.
28+
29+
$∑r_i−l_i+1$ should not exceed $2×10^7$.
30+
31+
**There must be an empty line at the end of the output!**
32+
33+
**If there are multiple solutions, you can print any of them.**
34+
35+
### Sample
36+
37+
#### Sample Input1
38+
39+
```
40+
4
41+
1 3 2 4
42+
```
43+
44+
#### Sample Output1
45+
46+
```
47+
2 3
48+
-1 -1
49+
```
50+
51+
#### Sample Input2
52+
53+
```
54+
4
55+
4 3 2 1
56+
```
57+
58+
#### Sample Output2
59+
60+
```
61+
1 3
62+
1 4
63+
2 4
64+
-1 -1
65+
```
66+
67+
#### Sample Input3
68+
69+
```
70+
10
71+
11 4 5 1 4 1 91 9 8 10
72+
```
73+
74+
#### Sample Output3
75+
76+
```
77+
1 2
78+
2 3
79+
3 5
80+
7 9
81+
5 7
82+
2 3
83+
5 6
84+
3 5
85+
1 4
86+
7 8
87+
9 10
88+
8 9
89+
-1 -1
90+
```
91+
92+
### Hint
93+
94+
For 10% testcases, $n≤5$.
95+
96+
For 20% testcases, $n≤500$.
97+
98+
For 30% testcases, $n≤5×10^3$.
99+
100+
For 50% testcases, $n≤1×10^4$.
101+
102+
For 70% testcases, $n≤3×10^4, a_i≤n$.
103+
104+
For 100% testcases, $n≤5×10^4$.

Lab8/Readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Lab8 Contest
2+
3+
| TITLE | Name | Score |
4+
| -------- | ------------------------ | ----- |
5+
| Lab8 - A | [Closest](A/) | |
6+
| Lab8 - B | [Urban Construction](B/) | |
7+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ I upload descriptions in [![](https://img.shields.io/badge/-Markdown-white?style
1616
| Lab 5 | [Shopping](Lab5/A/) | Y | [Voting](Lab5/B/) | Y |
1717
| Lab 6 | [Michael's Shopping Challenge](Lab6/A/) | | [Urban Planning](Lab6/B/) | |
1818
| Lab 7 | [Modify](Lab7/A/) | | [The Best Way to Wipe out a Friendship](Lab7/A/) | |
19+
| Lab 8 | [Closest](Lab8/A/) | | [Urban Construction](Lab8/B/) | |
1920

0 commit comments

Comments
 (0)