Skip to content

Commit 59a5f11

Browse files
committed
add cp21 with some example problems
0 parents  commit 59a5f11

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+3314
-0
lines changed

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Competitive Programming specific part
2+
/*/*/*/build/
3+
/*/*/notes.pdf
4+
/*/*/contest.pdf
5+
/login.toml
6+
/timefactor
7+
__pycache__/
8+
9+
# clion specific part
10+
.idea/
11+
cmake-build-*
12+
CMakeLists.txt
13+

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "tools"]
2+
path = tools
3+
url = [email protected]:compprog-lecture-tools/problem-tools.git

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
In this repo we collect problems build by students.
3+
4+
Please open a pull request so we can give you feedback.
5+
6+
Documentation regarding problem building can be found in the problem-tools repository.

cp21/fun-contest/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../tools/make/ContestMakefile

cp21/fun-contest/chocolate/.template

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../templates/description/template

cp21/fun-contest/chocolate/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../tools/make/Makefile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
timelimit=1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from pathlib import Path
2+
import random as r
3+
4+
TESTCASES = [
5+
('sample1', '1 1', 'Sample 1x1'),
6+
('sample2', '2 1', 'Sample 2x1'),
7+
('sample3', '2 2', 'Sample 1x2'),
8+
('25x25', '25 25', 'Hard testcase')
9+
]
10+
11+
for name, in_data, description in TESTCASES:
12+
Path(name + '.in').write_text(in_data + '\n')
13+
Path(name + '.desc').write_text(description + '\n')
14+
15+
for i in range(1,21):
16+
Path('random' + str(i) + '.in').write_text(str(r.randint(100, 10000)) + ' ' + str(r.randint(100, 10000)) + '\n')
17+
Path('random' + str(i) + '.desc').write_text('random testcase ' + str(i) + '\n')
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#include <unistd.h>
2+
3+
using namespace std;
4+
5+
int main() {
6+
char buf[14];
7+
8+
int w = 0;
9+
int h = 0;
10+
read(0, buf, 14);
11+
auto* ptr = buf;
12+
while (*ptr != ' ') {
13+
w *= 10;
14+
w += *ptr++ - '0';
15+
}
16+
++ptr;
17+
while (*ptr != '\n') {
18+
h *= 10;
19+
h += *ptr++ - '0';
20+
}
21+
22+
auto result = w * h - 1;
23+
ptr = buf + 13;
24+
*ptr-- = '\n';
25+
if (result == 0) {
26+
*ptr-- = '0';
27+
} else {
28+
while (result > 0) {
29+
*ptr-- = result % 10 + '0';
30+
result /= 10;
31+
}
32+
}
33+
34+
write(1, ptr + 1, buf + 13 - ptr - 1);
35+
return 0;
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
w, h = map(int, input().split())
2+
3+
print(w*h-1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/python3
2+
3+
print([w*h-1 for w, h in [map(int, input().split())]][0])
4+

0 commit comments

Comments
 (0)