algorithms

Algorithm implementations
git clone git://git.laack.co/algorithms.git
Log | Files | Refs | README

commit cd956f6d2ffd2b8679c841d2bf4876442eceda64
parent 53e1f23ef5dcd5a03a70eb7f3ad78d9bfd75502b
Author: Andrew Laack <andrew@laack.co>
Date:   Fri, 11 Sep 2026 15:50:00 -0500

Some cf work

Diffstat:
Acomp/shortest-path-of-the-king/problem.txt | 46++++++++++++++++++++++++++++++++++++++++++++++
Acomp/shortest-path-of-the-king/solution.cpp | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acomp/shortest-path-of-the-king/tests/0.in | 2++
Acomp/shortest-path-of-the-king/tests/1.in | 2++
Acomp/shortest-path-of-the-king/tests/2.in | 2++
Acomp/shortest-path-of-the-king/tests/3.in | 2++
Acomp/watermelon/problem.txt | 27+++++++++++++++++++++++++++
Acomp/watermelon/solution.cpp | 24++++++++++++++++++++++++
Acomp/watermelon/tests/1.in | 2++
Acomp/watermelon/tests/10.in | 2++
Acomp/watermelon/tests/100.in | 2++
Acomp/watermelon/tests/11.in | 2++
Acomp/watermelon/tests/12.in | 2++
Acomp/watermelon/tests/13.in | 2++
Acomp/watermelon/tests/14.in | 2++
Acomp/watermelon/tests/15.in | 2++
Acomp/watermelon/tests/16.in | 2++
Acomp/watermelon/tests/17.in | 2++
Acomp/watermelon/tests/18.in | 2++
Acomp/watermelon/tests/19.in | 2++
Acomp/watermelon/tests/2.in | 2++
Acomp/watermelon/tests/20.in | 2++
Acomp/watermelon/tests/21.in | 2++
Acomp/watermelon/tests/22.in | 2++
Acomp/watermelon/tests/23.in | 2++
Acomp/watermelon/tests/24.in | 2++
Acomp/watermelon/tests/25.in | 2++
Acomp/watermelon/tests/26.in | 2++
Acomp/watermelon/tests/27.in | 2++
Acomp/watermelon/tests/28.in | 2++
Acomp/watermelon/tests/29.in | 2++
Acomp/watermelon/tests/3.in | 2++
Acomp/watermelon/tests/30.in | 2++
Acomp/watermelon/tests/31.in | 2++
Acomp/watermelon/tests/32.in | 2++
Acomp/watermelon/tests/33.in | 2++
Acomp/watermelon/tests/34.in | 2++
Acomp/watermelon/tests/35.in | 2++
Acomp/watermelon/tests/36.in | 2++
Acomp/watermelon/tests/37.in | 2++
Acomp/watermelon/tests/38.in | 2++
Acomp/watermelon/tests/39.in | 2++
Acomp/watermelon/tests/4.in | 2++
Acomp/watermelon/tests/40.in | 2++
Acomp/watermelon/tests/41.in | 2++
Acomp/watermelon/tests/42.in | 2++
Acomp/watermelon/tests/43.in | 2++
Acomp/watermelon/tests/44.in | 2++
Acomp/watermelon/tests/45.in | 2++
Acomp/watermelon/tests/46.in | 2++
Acomp/watermelon/tests/47.in | 2++
Acomp/watermelon/tests/48.in | 2++
Acomp/watermelon/tests/49.in | 2++
Acomp/watermelon/tests/5.in | 2++
Acomp/watermelon/tests/50.in | 2++
Acomp/watermelon/tests/51.in | 2++
Acomp/watermelon/tests/52.in | 2++
Acomp/watermelon/tests/53.in | 2++
Acomp/watermelon/tests/54.in | 2++
Acomp/watermelon/tests/55.in | 2++
Acomp/watermelon/tests/56.in | 2++
Acomp/watermelon/tests/57.in | 2++
Acomp/watermelon/tests/58.in | 2++
Acomp/watermelon/tests/59.in | 2++
Acomp/watermelon/tests/6.in | 2++
Acomp/watermelon/tests/60.in | 2++
Acomp/watermelon/tests/61.in | 2++
Acomp/watermelon/tests/62.in | 2++
Acomp/watermelon/tests/63.in | 2++
Acomp/watermelon/tests/64.in | 2++
Acomp/watermelon/tests/65.in | 2++
Acomp/watermelon/tests/66.in | 2++
Acomp/watermelon/tests/67.in | 2++
Acomp/watermelon/tests/68.in | 2++
Acomp/watermelon/tests/69.in | 2++
Acomp/watermelon/tests/7.in | 2++
Acomp/watermelon/tests/70.in | 2++
Acomp/watermelon/tests/71.in | 2++
Acomp/watermelon/tests/72.in | 2++
Acomp/watermelon/tests/73.in | 2++
Acomp/watermelon/tests/74.in | 2++
Acomp/watermelon/tests/75.in | 2++
Acomp/watermelon/tests/76.in | 2++
Acomp/watermelon/tests/77.in | 2++
Acomp/watermelon/tests/78.in | 2++
Acomp/watermelon/tests/79.in | 2++
Acomp/watermelon/tests/8.in | 2++
Acomp/watermelon/tests/80.in | 2++
Acomp/watermelon/tests/81.in | 2++
Acomp/watermelon/tests/82.in | 2++
Acomp/watermelon/tests/83.in | 2++
Acomp/watermelon/tests/84.in | 2++
Acomp/watermelon/tests/85.in | 2++
Acomp/watermelon/tests/86.in | 2++
Acomp/watermelon/tests/87.in | 2++
Acomp/watermelon/tests/88.in | 2++
Acomp/watermelon/tests/89.in | 2++
Acomp/watermelon/tests/9.in | 2++
Acomp/watermelon/tests/90.in | 2++
Acomp/watermelon/tests/91.in | 2++
Acomp/watermelon/tests/92.in | 2++
Acomp/watermelon/tests/93.in | 2++
Acomp/watermelon/tests/94.in | 2++
Acomp/watermelon/tests/95.in | 2++
Acomp/watermelon/tests/96.in | 2++
Acomp/watermelon/tests/97.in | 2++
Acomp/watermelon/tests/98.in | 2++
Acomp/watermelon/tests/99.in | 2++
Acomp/watermelon/tests/gen_tests.py | 24++++++++++++++++++++++++
109 files changed, 388 insertions(+), 0 deletions(-)

diff --git a/comp/shortest-path-of-the-king/problem.txt b/comp/shortest-path-of-the-king/problem.txt @@ -0,0 +1,46 @@ +https://codeforces.com/problemset/problem/3/A + +A. Shortest path of the king + +The king is left alone on the chessboard. In spite of this loneliness, he doesn't lose heart, because he has business of national importance. For example, he has to pay an official visit to square t. As the king is not in habit of wasting his time, he wants to get from his current position s to square t in the least number of moves. Help him to do this. + +8 +7 +6 +5 +4 +3 +2 +1 + A B C D E F G H + +In one move the king can get to the square that has a common side or a common vertex with the square the king is currently in (generally there are 8 different squares he can move to). + +Input + +The first line contains the chessboard coordinates of square s, the second line — of square t. + +Chessboard coordinates consist of two characters, the first one is a lowercase Latin letter (from a to h), the second one is a digit from 1 to 8. + +Output + +In the first line print n — minimum number of the king's moves. Then in n lines print the moves themselves. Each move is described with one of the 8: L, R, U, D, LU, LD, RU or RD. + +L, R, U, D stand respectively for moves left, right, up and down (according to the picture), and 2-letter combinations stand for diagonal moves. If the answer is not unique, print any of them. + +Examples +Input + +a8 +h1 + +Output + +7 +RD +RD +RD +RD +RD +RD +RD diff --git a/comp/shortest-path-of-the-king/solution.cpp b/comp/shortest-path-of-the-king/solution.cpp @@ -0,0 +1,59 @@ +#include <iostream> +#include <vector> + +using namespace std; +int main() { + char kCol, tCol; + int kRow, tRow; + + cin >> kCol; + cin >> kRow; + + cin >> tCol; + cin >> tRow; + + int step = 0; + vector<string> steps{}; + + while(kCol != tCol || kRow != tRow) { + + string colMove, rowMove; + colMove = ""; + rowMove = ""; + + if(kCol != tCol) { + if(kCol > tCol) { + kCol -= 1; + colMove = "L"; + } + else { + kCol += 1; + colMove = "R"; + } + + } + if(kRow != tRow) { + if(kRow > tRow) { + kRow -= 1; + rowMove = "D"; + } + else { + kRow += 1; + rowMove = "U"; + } + } + + string res = colMove + rowMove; + steps.push_back(res); + step += 1; + + } + + cout << step << endl; + + for(auto step : steps) { + cout << step << endl; + } + + +} diff --git a/comp/shortest-path-of-the-king/tests/0.in b/comp/shortest-path-of-the-king/tests/0.in @@ -0,0 +1,2 @@ +a8 +h1 diff --git a/comp/shortest-path-of-the-king/tests/1.in b/comp/shortest-path-of-the-king/tests/1.in @@ -0,0 +1,2 @@ +a8 +a8 diff --git a/comp/shortest-path-of-the-king/tests/2.in b/comp/shortest-path-of-the-king/tests/2.in @@ -0,0 +1,2 @@ +f1 +b1 diff --git a/comp/shortest-path-of-the-king/tests/3.in b/comp/shortest-path-of-the-king/tests/3.in @@ -0,0 +1,2 @@ +b2 +b4 diff --git a/comp/watermelon/problem.txt b/comp/watermelon/problem.txt @@ -0,0 +1,27 @@ +https://codeforces.com/problemset/problem/4/A + +A. Watermelon + +One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem. + +Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight. + +Input + +The first (and the only) input line contains integer number w (1 ≤ w ≤ 100) — the weight of the watermelon bought by the boys. + +Output + +Print YES, if the boys can divide the watermelon into two parts, each of them weighing even number of kilos; and NO in the opposite case. + +Examples + +Input +8 + +Output +YES + +Note + +For example, the boys can divide the watermelon into two parts of 2 and 6 kilos respectively (another variant — two parts of 4 and 4 kilos). diff --git a/comp/watermelon/solution.cpp b/comp/watermelon/solution.cpp @@ -0,0 +1,24 @@ +// 4/A + +#include<iostream> + +using namespace std; + +// One hot summer day Pete and his friend Billy decided to buy a watermelon. They chose the biggest and the ripest one, in their opinion. After that the watermelon was weighed, and the scales showed w kilos. They rushed home, dying of thirst, and decided to divide the berry, however they faced a hard problem. + +// Pete and Billy are great fans of even numbers, that's why they want to divide the watermelon in such a way that each of the two parts weighs even number of kilos, at the same time it is not obligatory that the parts are equal. The boys are extremely tired and want to start their meal as soon as possible, that's why you should help them and find out, if they can divide the watermelon in the way they want. For sure, each of them should get a part of positive weight. + +// w = weight in kilos + +int main() { + int w; + cin >> w; + + if(w % 2 == 0 && w > 2) { + cout << "YES"; + return 0; + } + + cout << "NO"; + return 0; +} diff --git a/comp/watermelon/tests/1.in b/comp/watermelon/tests/1.in @@ -0,0 +1 @@ +1+ \ No newline at end of file diff --git a/comp/watermelon/tests/10.in b/comp/watermelon/tests/10.in @@ -0,0 +1 @@ +10+ \ No newline at end of file diff --git a/comp/watermelon/tests/100.in b/comp/watermelon/tests/100.in @@ -0,0 +1 @@ +100+ \ No newline at end of file diff --git a/comp/watermelon/tests/11.in b/comp/watermelon/tests/11.in @@ -0,0 +1 @@ +11+ \ No newline at end of file diff --git a/comp/watermelon/tests/12.in b/comp/watermelon/tests/12.in @@ -0,0 +1 @@ +12+ \ No newline at end of file diff --git a/comp/watermelon/tests/13.in b/comp/watermelon/tests/13.in @@ -0,0 +1 @@ +13+ \ No newline at end of file diff --git a/comp/watermelon/tests/14.in b/comp/watermelon/tests/14.in @@ -0,0 +1 @@ +14+ \ No newline at end of file diff --git a/comp/watermelon/tests/15.in b/comp/watermelon/tests/15.in @@ -0,0 +1 @@ +15+ \ No newline at end of file diff --git a/comp/watermelon/tests/16.in b/comp/watermelon/tests/16.in @@ -0,0 +1 @@ +16+ \ No newline at end of file diff --git a/comp/watermelon/tests/17.in b/comp/watermelon/tests/17.in @@ -0,0 +1 @@ +17+ \ No newline at end of file diff --git a/comp/watermelon/tests/18.in b/comp/watermelon/tests/18.in @@ -0,0 +1 @@ +18+ \ No newline at end of file diff --git a/comp/watermelon/tests/19.in b/comp/watermelon/tests/19.in @@ -0,0 +1 @@ +19+ \ No newline at end of file diff --git a/comp/watermelon/tests/2.in b/comp/watermelon/tests/2.in @@ -0,0 +1 @@ +2+ \ No newline at end of file diff --git a/comp/watermelon/tests/20.in b/comp/watermelon/tests/20.in @@ -0,0 +1 @@ +20+ \ No newline at end of file diff --git a/comp/watermelon/tests/21.in b/comp/watermelon/tests/21.in @@ -0,0 +1 @@ +21+ \ No newline at end of file diff --git a/comp/watermelon/tests/22.in b/comp/watermelon/tests/22.in @@ -0,0 +1 @@ +22+ \ No newline at end of file diff --git a/comp/watermelon/tests/23.in b/comp/watermelon/tests/23.in @@ -0,0 +1 @@ +23+ \ No newline at end of file diff --git a/comp/watermelon/tests/24.in b/comp/watermelon/tests/24.in @@ -0,0 +1 @@ +24+ \ No newline at end of file diff --git a/comp/watermelon/tests/25.in b/comp/watermelon/tests/25.in @@ -0,0 +1 @@ +25+ \ No newline at end of file diff --git a/comp/watermelon/tests/26.in b/comp/watermelon/tests/26.in @@ -0,0 +1 @@ +26+ \ No newline at end of file diff --git a/comp/watermelon/tests/27.in b/comp/watermelon/tests/27.in @@ -0,0 +1 @@ +27+ \ No newline at end of file diff --git a/comp/watermelon/tests/28.in b/comp/watermelon/tests/28.in @@ -0,0 +1 @@ +28+ \ No newline at end of file diff --git a/comp/watermelon/tests/29.in b/comp/watermelon/tests/29.in @@ -0,0 +1 @@ +29+ \ No newline at end of file diff --git a/comp/watermelon/tests/3.in b/comp/watermelon/tests/3.in @@ -0,0 +1 @@ +3+ \ No newline at end of file diff --git a/comp/watermelon/tests/30.in b/comp/watermelon/tests/30.in @@ -0,0 +1 @@ +30+ \ No newline at end of file diff --git a/comp/watermelon/tests/31.in b/comp/watermelon/tests/31.in @@ -0,0 +1 @@ +31+ \ No newline at end of file diff --git a/comp/watermelon/tests/32.in b/comp/watermelon/tests/32.in @@ -0,0 +1 @@ +32+ \ No newline at end of file diff --git a/comp/watermelon/tests/33.in b/comp/watermelon/tests/33.in @@ -0,0 +1 @@ +33+ \ No newline at end of file diff --git a/comp/watermelon/tests/34.in b/comp/watermelon/tests/34.in @@ -0,0 +1 @@ +34+ \ No newline at end of file diff --git a/comp/watermelon/tests/35.in b/comp/watermelon/tests/35.in @@ -0,0 +1 @@ +35+ \ No newline at end of file diff --git a/comp/watermelon/tests/36.in b/comp/watermelon/tests/36.in @@ -0,0 +1 @@ +36+ \ No newline at end of file diff --git a/comp/watermelon/tests/37.in b/comp/watermelon/tests/37.in @@ -0,0 +1 @@ +37+ \ No newline at end of file diff --git a/comp/watermelon/tests/38.in b/comp/watermelon/tests/38.in @@ -0,0 +1 @@ +38+ \ No newline at end of file diff --git a/comp/watermelon/tests/39.in b/comp/watermelon/tests/39.in @@ -0,0 +1 @@ +39+ \ No newline at end of file diff --git a/comp/watermelon/tests/4.in b/comp/watermelon/tests/4.in @@ -0,0 +1 @@ +4+ \ No newline at end of file diff --git a/comp/watermelon/tests/40.in b/comp/watermelon/tests/40.in @@ -0,0 +1 @@ +40+ \ No newline at end of file diff --git a/comp/watermelon/tests/41.in b/comp/watermelon/tests/41.in @@ -0,0 +1 @@ +41+ \ No newline at end of file diff --git a/comp/watermelon/tests/42.in b/comp/watermelon/tests/42.in @@ -0,0 +1 @@ +42+ \ No newline at end of file diff --git a/comp/watermelon/tests/43.in b/comp/watermelon/tests/43.in @@ -0,0 +1 @@ +43+ \ No newline at end of file diff --git a/comp/watermelon/tests/44.in b/comp/watermelon/tests/44.in @@ -0,0 +1 @@ +44+ \ No newline at end of file diff --git a/comp/watermelon/tests/45.in b/comp/watermelon/tests/45.in @@ -0,0 +1 @@ +45+ \ No newline at end of file diff --git a/comp/watermelon/tests/46.in b/comp/watermelon/tests/46.in @@ -0,0 +1 @@ +46+ \ No newline at end of file diff --git a/comp/watermelon/tests/47.in b/comp/watermelon/tests/47.in @@ -0,0 +1 @@ +47+ \ No newline at end of file diff --git a/comp/watermelon/tests/48.in b/comp/watermelon/tests/48.in @@ -0,0 +1 @@ +48+ \ No newline at end of file diff --git a/comp/watermelon/tests/49.in b/comp/watermelon/tests/49.in @@ -0,0 +1 @@ +49+ \ No newline at end of file diff --git a/comp/watermelon/tests/5.in b/comp/watermelon/tests/5.in @@ -0,0 +1 @@ +5+ \ No newline at end of file diff --git a/comp/watermelon/tests/50.in b/comp/watermelon/tests/50.in @@ -0,0 +1 @@ +50+ \ No newline at end of file diff --git a/comp/watermelon/tests/51.in b/comp/watermelon/tests/51.in @@ -0,0 +1 @@ +51+ \ No newline at end of file diff --git a/comp/watermelon/tests/52.in b/comp/watermelon/tests/52.in @@ -0,0 +1 @@ +52+ \ No newline at end of file diff --git a/comp/watermelon/tests/53.in b/comp/watermelon/tests/53.in @@ -0,0 +1 @@ +53+ \ No newline at end of file diff --git a/comp/watermelon/tests/54.in b/comp/watermelon/tests/54.in @@ -0,0 +1 @@ +54+ \ No newline at end of file diff --git a/comp/watermelon/tests/55.in b/comp/watermelon/tests/55.in @@ -0,0 +1 @@ +55+ \ No newline at end of file diff --git a/comp/watermelon/tests/56.in b/comp/watermelon/tests/56.in @@ -0,0 +1 @@ +56+ \ No newline at end of file diff --git a/comp/watermelon/tests/57.in b/comp/watermelon/tests/57.in @@ -0,0 +1 @@ +57+ \ No newline at end of file diff --git a/comp/watermelon/tests/58.in b/comp/watermelon/tests/58.in @@ -0,0 +1 @@ +58+ \ No newline at end of file diff --git a/comp/watermelon/tests/59.in b/comp/watermelon/tests/59.in @@ -0,0 +1 @@ +59+ \ No newline at end of file diff --git a/comp/watermelon/tests/6.in b/comp/watermelon/tests/6.in @@ -0,0 +1 @@ +6+ \ No newline at end of file diff --git a/comp/watermelon/tests/60.in b/comp/watermelon/tests/60.in @@ -0,0 +1 @@ +60+ \ No newline at end of file diff --git a/comp/watermelon/tests/61.in b/comp/watermelon/tests/61.in @@ -0,0 +1 @@ +61+ \ No newline at end of file diff --git a/comp/watermelon/tests/62.in b/comp/watermelon/tests/62.in @@ -0,0 +1 @@ +62+ \ No newline at end of file diff --git a/comp/watermelon/tests/63.in b/comp/watermelon/tests/63.in @@ -0,0 +1 @@ +63+ \ No newline at end of file diff --git a/comp/watermelon/tests/64.in b/comp/watermelon/tests/64.in @@ -0,0 +1 @@ +64+ \ No newline at end of file diff --git a/comp/watermelon/tests/65.in b/comp/watermelon/tests/65.in @@ -0,0 +1 @@ +65+ \ No newline at end of file diff --git a/comp/watermelon/tests/66.in b/comp/watermelon/tests/66.in @@ -0,0 +1 @@ +66+ \ No newline at end of file diff --git a/comp/watermelon/tests/67.in b/comp/watermelon/tests/67.in @@ -0,0 +1 @@ +67+ \ No newline at end of file diff --git a/comp/watermelon/tests/68.in b/comp/watermelon/tests/68.in @@ -0,0 +1 @@ +68+ \ No newline at end of file diff --git a/comp/watermelon/tests/69.in b/comp/watermelon/tests/69.in @@ -0,0 +1 @@ +69+ \ No newline at end of file diff --git a/comp/watermelon/tests/7.in b/comp/watermelon/tests/7.in @@ -0,0 +1 @@ +7+ \ No newline at end of file diff --git a/comp/watermelon/tests/70.in b/comp/watermelon/tests/70.in @@ -0,0 +1 @@ +70+ \ No newline at end of file diff --git a/comp/watermelon/tests/71.in b/comp/watermelon/tests/71.in @@ -0,0 +1 @@ +71+ \ No newline at end of file diff --git a/comp/watermelon/tests/72.in b/comp/watermelon/tests/72.in @@ -0,0 +1 @@ +72+ \ No newline at end of file diff --git a/comp/watermelon/tests/73.in b/comp/watermelon/tests/73.in @@ -0,0 +1 @@ +73+ \ No newline at end of file diff --git a/comp/watermelon/tests/74.in b/comp/watermelon/tests/74.in @@ -0,0 +1 @@ +74+ \ No newline at end of file diff --git a/comp/watermelon/tests/75.in b/comp/watermelon/tests/75.in @@ -0,0 +1 @@ +75+ \ No newline at end of file diff --git a/comp/watermelon/tests/76.in b/comp/watermelon/tests/76.in @@ -0,0 +1 @@ +76+ \ No newline at end of file diff --git a/comp/watermelon/tests/77.in b/comp/watermelon/tests/77.in @@ -0,0 +1 @@ +77+ \ No newline at end of file diff --git a/comp/watermelon/tests/78.in b/comp/watermelon/tests/78.in @@ -0,0 +1 @@ +78+ \ No newline at end of file diff --git a/comp/watermelon/tests/79.in b/comp/watermelon/tests/79.in @@ -0,0 +1 @@ +79+ \ No newline at end of file diff --git a/comp/watermelon/tests/8.in b/comp/watermelon/tests/8.in @@ -0,0 +1 @@ +8+ \ No newline at end of file diff --git a/comp/watermelon/tests/80.in b/comp/watermelon/tests/80.in @@ -0,0 +1 @@ +80+ \ No newline at end of file diff --git a/comp/watermelon/tests/81.in b/comp/watermelon/tests/81.in @@ -0,0 +1 @@ +81+ \ No newline at end of file diff --git a/comp/watermelon/tests/82.in b/comp/watermelon/tests/82.in @@ -0,0 +1 @@ +82+ \ No newline at end of file diff --git a/comp/watermelon/tests/83.in b/comp/watermelon/tests/83.in @@ -0,0 +1 @@ +83+ \ No newline at end of file diff --git a/comp/watermelon/tests/84.in b/comp/watermelon/tests/84.in @@ -0,0 +1 @@ +84+ \ No newline at end of file diff --git a/comp/watermelon/tests/85.in b/comp/watermelon/tests/85.in @@ -0,0 +1 @@ +85+ \ No newline at end of file diff --git a/comp/watermelon/tests/86.in b/comp/watermelon/tests/86.in @@ -0,0 +1 @@ +86+ \ No newline at end of file diff --git a/comp/watermelon/tests/87.in b/comp/watermelon/tests/87.in @@ -0,0 +1 @@ +87+ \ No newline at end of file diff --git a/comp/watermelon/tests/88.in b/comp/watermelon/tests/88.in @@ -0,0 +1 @@ +88+ \ No newline at end of file diff --git a/comp/watermelon/tests/89.in b/comp/watermelon/tests/89.in @@ -0,0 +1 @@ +89+ \ No newline at end of file diff --git a/comp/watermelon/tests/9.in b/comp/watermelon/tests/9.in @@ -0,0 +1 @@ +9+ \ No newline at end of file diff --git a/comp/watermelon/tests/90.in b/comp/watermelon/tests/90.in @@ -0,0 +1 @@ +90+ \ No newline at end of file diff --git a/comp/watermelon/tests/91.in b/comp/watermelon/tests/91.in @@ -0,0 +1 @@ +91+ \ No newline at end of file diff --git a/comp/watermelon/tests/92.in b/comp/watermelon/tests/92.in @@ -0,0 +1 @@ +92+ \ No newline at end of file diff --git a/comp/watermelon/tests/93.in b/comp/watermelon/tests/93.in @@ -0,0 +1 @@ +93+ \ No newline at end of file diff --git a/comp/watermelon/tests/94.in b/comp/watermelon/tests/94.in @@ -0,0 +1 @@ +94+ \ No newline at end of file diff --git a/comp/watermelon/tests/95.in b/comp/watermelon/tests/95.in @@ -0,0 +1 @@ +95+ \ No newline at end of file diff --git a/comp/watermelon/tests/96.in b/comp/watermelon/tests/96.in @@ -0,0 +1 @@ +96+ \ No newline at end of file diff --git a/comp/watermelon/tests/97.in b/comp/watermelon/tests/97.in @@ -0,0 +1 @@ +97+ \ No newline at end of file diff --git a/comp/watermelon/tests/98.in b/comp/watermelon/tests/98.in @@ -0,0 +1 @@ +98+ \ No newline at end of file diff --git a/comp/watermelon/tests/99.in b/comp/watermelon/tests/99.in @@ -0,0 +1 @@ +99+ \ No newline at end of file diff --git a/comp/watermelon/tests/gen_tests.py b/comp/watermelon/tests/gen_tests.py @@ -0,0 +1,24 @@ +import os + +# we want to be exhaustive in our search even though the heuristic is known. +def can_div(num): + for x in range(1,num+1): + for y in range(1,num+1): + if x%2 != 0 or y%2 != 0: + continue + if x + y == num: + return True + return False + + +for i in range(1,101): + in_file = str(i) + ".in" + out_file = str(i) + ".out" + + with open(in_file, 'w') as in_file: + with open(out_file, 'w') as out_file: + in_file.write(str(i)) + st_write = "NO" + if can_div(i): + st_write = "YES" + out_file.write(st_write)