report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Parking - FlandreOJ: Flandre Online Judge

Parking

Time limit: 1000 ms
Memory limit: 256 MB
There are $n$ slots on a circular parking enumerated from $1$ to $n$. There are $n$ cars that want to park in the natural order. $i^{th}$ car wants to park at ${p_i}^{th}$ slot. If the car drives to a parking slot and her slot is occupied, it drives in a circular manner and parks on the first vacant slot. ### Input - The first line contains integer $n$, the size of the parking and the number of cars. - The second line contains $n$ integers, the slot that wants to be occupied by car $i$. ### Output Output $n$ numbers. $i^{th}$ number should be the parking slot which was occupied by $i^{th}$ car. ### Constraints - $1 \le n \le 10^5$. - $1 \le p_i \le n$. ### Example Input: ``` 3 2 2 2 ``` Output: ``` 2 3 1 ```
Disjoint Set Union (DSU)
DSU
Component sum
Minimum spanning tree
Parking
Remove edge
Yet another problem
Assignment query on tree
Watering
Minimum spanning tree 2
Fatal meal
Statement
All pairs
Query on tree
Minimum spanning tree 3
Topic
DSU
Rating 1100
Source Codeforces
Solution (3) Solution