Skip to content

Commit f77f768

Browse files
committed
add gridbfs topic, and restructure course-page
1 parent 8bde229 commit f77f768

File tree

4 files changed

+71
-44
lines changed

4 files changed

+71
-44
lines changed

_compprogcourse/01_intro.html

Lines changed: 0 additions & 29 deletions
This file was deleted.

_compprogcourse/01_intro.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
layout: panel
3+
title: Intro
4+
---
5+
6+
## Intro
7+
8+
### Problems
9+
- [Daydreaming Stockbroker](https://open.kattis.com/problems/stockbroker)
10+
- [Billiard](https://open.kattis.com/problems/billiard)
11+
- [Pairing Socks](https://open.kattis.com/problems/pairingsocks)
12+
- [Boiling Vegetables](https://open.kattis.com/problems/vegetables)
13+
- [Opening Ceremony](https://open.kattis.com/problems/ceremony)
14+
- [Fractal](https://open.kattis.com/problems/fractal2)
15+
16+
Here are a couple of problems where each solution demonstrates some concept that is quite common at programming competitions. For an experienced competitve programmare, who has seen all these techniques before most of these problems would be classified as easy. They are however chosen so that they become a challange for someone who is new to competitive programming. Please move on to the next topic when you've solved a few of these!
17+
18+
Note that your program is tested on secret inputs. Your program has to produce the correct output for all secrets inputs. You can however be sure that the secret inputs follow the input format given in the problem statement.
19+
20+
When your program is not accepted, there can be some different errors, which are described with error codes. I plan to add some tips about the error codes in the future.

_compprogcourse/02_grid_bfs.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
layout: panel
3+
title: Grid BFS
4+
---
5+
6+
## BFS in Grids
7+
8+
### Problems
9+
- [Grid](https://open.kattis.com/problems/grid)
10+
- [Coast Length](https://open.kattis.com/problems/coast)
11+
- [Terraces](https://open.kattis.com/problems/terraces)
12+
- [Dacey the Dice](https://open.kattis.com/problems/daceydice)
13+
- [Wet Tiles](https://open.kattis.com/problems/wettiles)
14+
- [Fire](https://open.kattis.com/problems/fire2)
15+
- [10 Kinds of People](https://open.kattis.com/problems/10kindsofpeople)
16+
- [Horror List](https://open.kattis.com/problems/horror)
17+
- [Lava](https://open.kattis.com/problems/lava)
18+
- [Zoning](https://open.kattis.com/problems/zoning)
19+
- [Pokémon Ice Maze](https://open.kattis.com/problems/pokemon)
20+
21+
Breath First Search is a technique to find shortest paths in unweighted graphs. All nodes are preccessed in order of how far away they are from the starting node. Todo this, commonly we use a FIFO-queue. In python deque is a double ended queue and can be used as a FIFO-queue. This week we will focus on grids, and view them as graphs. All the neighbours of a grid cell is easy to find, there are at most 4, all the adjacent cells. The following code performs a BFS from the cell `(startx, starty)`, in an `N` by `M` grid.
22+
23+
```python
24+
from collections import deque
25+
def BFS(startx, starty):
26+
q = deque([(startx, starty)])
27+
dist = {(startx, starty): 0}
28+
while q:
29+
x, y = q.popleft()
30+
for nx, ny in [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]:
31+
if 0 <= nx < N and 0 <= ny < M:
32+
coord = nx, ny
33+
if coord not in dist:
34+
dist[coord] = dist[x, y] + 1
35+
q.append(coord)
36+
return dist
37+
```
38+
39+
However, this is not of any use yet, since the manhattan distance can be calculated directly. This code is however of use if the grid has cells that are forbidden to visit. Then those cells can be filtered out at the same place as cells outside the grid are filtered out now. Then we can find the shortest distance in a maze.

resources/compprog/course.html

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,35 @@ <h2>Competitive Programming Course</h2>
1212
</div>
1313
</div>
1414
<div class="row">
15-
<div class="col-md-6">
15+
<div class="col-lg-6" style="margin-bottom:2%">
1616
<p>
1717
This course aims to help you train for upcoming programming competitions. Please don't feel the urge to not compete before finish this course, or before you solve all the problems linked. The best practice is to participate.
1818
</p>
1919
</div>
2020
</div>
2121
<div class="row">
2222
<div class="col-md-6">
23+
<h3>Topics</h3>
24+
<ul>
25+
{% for topic in site.compprogcourse %}
26+
<li><a href="{{ topic.url | prepend: site.baseurl }}">{{ topic.title }}</a></li>
27+
{% endfor %}
28+
</ul>
29+
</div>
30+
<div class="col-md-6" style="margin-top:2%">
2331

24-
<p> This course focuses on a subset of competitions with the following restrictions:</p>
32+
<p> Focuses on competitions with the following restrictions:</p>
2533

2634
<ul>
2735
<li>The output of your algorithm is either correct or not correct, there are no problems that you can solve partially.</li>
28-
<li>Your code for a problem is submitted to a judge server that runs your code with a time limit on some hidder testcases.</li>
36+
<li>Your code for a problem is submitted to a judge server that runs your code with a time limit on some hidden testcases.</li>
2937
<li>You use a <a href="https://open.kattis.com/help">language supported by Kattis</a>, since the problems we will use are hosted at Kattis.</li>
3038
</ul>
31-
</div>
32-
<div class="col-md-6">
33-
<p> Preliminaries </p>
39+
<p> Preliminaries: </p>
3440
<ul>
3541
<li>Reading from stdin, printing to stdout. You can find information on how to do this in your prefered language on <a href="https://open.kattis.com/help">Kattis helppage</a> </li>
3642
<li>Basic data structures like Queue, Set, Map, Heap. Take the course <a href="http://cs.lth.se/edaa01/">EDAA01</a>, or read about these data structures on <a href="https://en.wikipedia.org/wiki/List_of_data_structures">wikipedia</a>.</li>
3743
<li>A Kattis-account, create one <a href="https://open.kattis.com/register">here</a>.</li>
3844
</ul>
3945
</div>
4046
</div>
41-
<div class="row">
42-
<div class="col-md-6">
43-
<ul>
44-
{% for topic in site.compprogcourse %}
45-
<li><a href="{{ topic.url | prepend: site.baseurl }}">{{ topic.title }}</a></li>
46-
{% endfor %}
47-
</ul>
48-
</div>
49-
</div>

0 commit comments

Comments
 (0)