File tree Expand file tree Collapse file tree 4 files changed +83
-2
lines changed Expand file tree Collapse file tree 4 files changed +83
-2
lines changed Original file line number Diff line number Diff line change @@ -309,6 +309,38 @@ def check(mid:int):
309309 return left if return_left else right
310310
311311
312+ class ChangeMin :
313+ def __init__ (self , x ) -> None :
314+ """Change min構造体
315+
316+ 代入時現在の値より代入する値が低ければ代入される
317+ setメソッドで代入する
318+ """
319+ self .x = x
320+
321+ def set (self , new ) -> None :
322+ self .x = min (self .x , new )
323+
324+ def val (self ) -> any :
325+ return self .x
326+
327+
328+ class ChangeMax :
329+ def __init__ (self , x ) -> None :
330+ """Change min構造体
331+
332+ 代入時現在の値より代入する値が大きければ代入される
333+ setメソッドで代入する
334+ """
335+ self .x = x
336+
337+ def set (self , new ) -> None :
338+ self .x = max (self .x , new )
339+
340+ def val (self ) -> any :
341+ return self .x
342+
343+
312344def mod_add (a : int , b : int , mod : int ) -> int :
313345 """足し算してmodを取った値を出力
314346
Original file line number Diff line number Diff line change 1+ class ChangeMin :
2+ def __init__ (self , x ) -> None :
3+ """Change min構造体
4+
5+ 代入時現在の値より代入する値が低ければ代入される
6+ setメソッドで代入する
7+ """
8+ self .x = x
9+
10+ def set (self , new ) -> None :
11+ self .x = min (self .x , new )
12+
13+ def val (self ) -> any :
14+ return self .x
15+
16+
17+ class ChangeMax :
18+ def __init__ (self , x ) -> None :
19+ """Change min構造体
20+
21+ 代入時現在の値より代入する値が大きければ代入される
22+ setメソッドで代入する
23+ """
24+ self .x = x
25+
26+ def set (self , new ) -> None :
27+ self .x = max (self .x , new )
28+
29+ def val (self ) -> any :
30+ return self .x
Original file line number Diff line number Diff line change @@ -7,9 +7,9 @@ echo "新しいmain.py作成完了"
77# テンプレ
88# /bin/cat python/<filename>.py >> code/main.py
99
10- for file_name in " import.py" " standard_input.py" " math_func.py" " array_create.py" " binary_search.py" " modint.py" " yn_func.py" " grid.py" " coordinates_to_id.py" " dijkstra.py" " get_path.py" " dp.py" " coordinate_compression.py" " memo.py" " rerooting.py" " manacher.py" " rollinghash.py" " graph.py" " unionfind.py" " euler_tour.py" " potential_unionfind.py" " heap.py" " trie.py" " mo.py" " square-division.py" " prefix_sum_2d.py" " dual_segtree.py" " dis_lib.py" " alias.py" " utils.py" ; do
10+ for file_name in " import.py" " standard_input.py" " math_func.py" " array_create.py" " binary_search.py" " change_minmax.py " " modint.py" " yn_func.py" " grid.py" " coordinates_to_id.py" " dijkstra.py" " get_path.py" " dp.py" " coordinate_compression.py" " memo.py" " rerooting.py" " manacher.py" " rollinghash.py" " graph.py" " unionfind.py" " euler_tour.py" " potential_unionfind.py" " heap.py" " trie.py" " mo.py" " square-division.py" " prefix_sum_2d.py" " dual_segtree.py" " dis_lib.py" " alias.py" " utils.py" ; do
1111
12- cat libs/${file_name} >> code/main.py
12+ cat libs/${file_name} >> code/main.py
1313done
1414
1515# function add_code() {
Original file line number Diff line number Diff line change 11# competitive-verifier: UNITTEST PYTHON_UNITTEST_RESULT
22import unittest
33
4+ from libs .change_minmax import ChangeMax , ChangeMin
45from libs .coordinate_compression import compress_1d
56from libs .euler_tour import EulerTour
67from libs .grid import coordinate_check
@@ -175,5 +176,23 @@ def test_eulertour(self) -> None:
175176 ET .change_edge_cost (l [1 ], l [2 ])
176177
177178
179+ class TestChangeMinMax (unittest .TestCase ):
180+ def test_change_min (self ) -> None :
181+ T = ChangeMin (5 )
182+ self .assertEqual (T .val (), 5 )
183+ T .set (6 )
184+ self .assertEqual (T .val (), 5 )
185+ T .set (3 )
186+ self .assertEqual (T .val (), 3 )
187+
188+ def test_change_max (self ) -> None :
189+ T = ChangeMax (5 )
190+ self .assertEqual (T .val (), 5 )
191+ T .set (3 )
192+ self .assertEqual (T .val (), 5 )
193+ T .set (6 )
194+ self .assertEqual (T .val (), 6 )
195+
196+
178197if __name__ == "__main__" :
179198 unittest .main ()
You can’t perform that action at this time.
0 commit comments