Educational Codeforces Round 178 (Rated for Div. 2)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
2104 Educational Codeforces Round 178 (Rated for Div. 2) FINISHED False 7200 30554723 April 28, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 522 ) G Modulo 3 PROGRAMMING data structures divide and conquer dsu trees

Surely, you have seen problems which require you to output the answer modulo (10^9+7), (10^9+9), or (998244353). But have you ever seen a problem where you have to print the answer modulo (3)? You are given a functional graph consisting of (n) vertices, numbered from (1) to (n). It is a directed graph, in which each vertex has exactly one outgoing arc. The graph is given as the array (g_1, g_2, \dots, g_n), where (g_i) means that there is an arc that goes from (i) to (g_i). For some vertices, the outgoing arcs might be self-loops. Initially, all vertices of the graph are colored in color (1). You can perform the following operation: select a vertex and a color from (1) to (k), and then color this vertex and all vertices that are reachable from it. You can perform this operation any number of times (even zero). You should process (q) queries. The query is described by three integers (x), (y) and (k). For each query, you should: assign (g_x := y); then calculate the number of different graph colorings for the given value of (k) (two colorings are different if there exists at least one vertex that is colored in different colors in these two colorings); since the answer can be very large, print it modulo (3) . Note that in every query, the initial coloring of the graph is reset (all vertices initially have color (1) in each query). The first line contains two integers (n) and (q) ((1 \le n, q \le 2 \cdot 10^5)). The second line contains (n) integers (g_1, g_2, \dots, g_n) ((1 \le g_i \le n)). The (q) lines follow. The (i)-th line contains three integers (x_i), (y_i) and (k_i) ((1 \le x_i, y_i \le n); (1 \le k_i \le 10^9)). For each query, print a single integer — the number of different graph colorings for the given value of (k), taken modulo (3).

Tutorials

Educational Codeforces Round 178 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
317668816 thinkphp G April 28, 2025, 7:19 p.m. OK C++17 (GCC 7-32) TESTS 15 718 69120000
317648587 akshitmittal G April 28, 2025, 4:26 p.m. OK C++17 (GCC 7-32) TESTS 15 734 63897600
317654762 jcelin G April 28, 2025, 5:07 p.m. OK C++17 (GCC 7-32) TESTS 15 765 64921600
317641594 bindpankaj G April 28, 2025, 4:09 p.m. OK C++17 (GCC 7-32) TESTS 15 796 64000000
317674550 Az3ar G April 28, 2025, 8:40 p.m. OK C++17 (GCC 7-32) TESTS 15 890 58982400
317649770 Aurora14526 G April 28, 2025, 4:29 p.m. OK C++17 (GCC 7-32) TESTS 15 1031 62976000
317644154 Kriz_Wu G April 28, 2025, 4:15 p.m. OK C++17 (GCC 7-32) TESTS 15 2890 143564800
317694688 Enoch006 G April 29, 2025, 4:49 a.m. OK C++17 (GCC 7-32) TESTS 15 3077 108134400
317647483 thisislike_fan G April 28, 2025, 4:23 p.m. OK C++20 (GCC 13-64) TESTS 15 577 28057600
317650669 kaushalmajeti G April 28, 2025, 4:31 p.m. OK C++20 (GCC 13-64) TESTS 15 671 76288000
317648544 Nikhilesh_Kancherla G April 28, 2025, 4:26 p.m. OK C++20 (GCC 13-64) TESTS 15 671 76288000
317642665 ChakradharN G April 28, 2025, 4:12 p.m. OK C++20 (GCC 13-64) TESTS 15 671 76288000
317651832 LingKerly G April 28, 2025, 4:33 p.m. OK C++20 (GCC 13-64) TESTS 15 671 78131200
317644072 oldEight G April 28, 2025, 4:15 p.m. OK C++20 (GCC 13-64) TESTS 15 671 80691200
317677384 __huangshan29 G April 28, 2025, 9:38 p.m. OK C++20 (GCC 13-64) TESTS 15 671 81510400
317659398 DQ1275 G April 28, 2025, 5:42 p.m. OK C++20 (GCC 13-64) TESTS 15 671 101888000
317654829 MrAndria G April 28, 2025, 5:07 p.m. OK C++20 (GCC 13-64) TESTS 15 671 180940800
317674307 elijjah G April 28, 2025, 8:36 p.m. OK C++20 (GCC 13-64) TESTS 15 686 72601600
317694489 enslaved G April 29, 2025, 4:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 592 21401600
317676425 Boboge G April 28, 2025, 9:15 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 609 68915200
317693954 dpaladiyaa G April 29, 2025, 4:35 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 640 76390400
317679427 BluoCaroot G April 28, 2025, 10:34 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 655 7270400
317656810 zhangwansen G April 28, 2025, 5:20 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 671 75980800
317655278 andrei_C1 G April 28, 2025, 5:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 702 75571200
317699593 inlovingmemory G April 29, 2025, 5:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 717 71065600
317693007 KisuraOP G April 29, 2025, 4:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 718 91750400
317680882 amit_dwivedi G April 28, 2025, 11:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 15 733 77414400
317685491 testforotherthings G April 29, 2025, 1:29 a.m. OK C++23 (GCC 14-64, msys2) TESTS 15 734 137830400
317651992 omdeshmukh1906 G April 28, 2025, 4:34 p.m. OK Java 8 TESTS 15 1765 118681600
317649092 _Khaled_Kamal G April 28, 2025, 4:27 p.m. OK Kotlin 1.9 TESTS 15 3437 161382400
317650958 darkkcyan G April 28, 2025, 4:32 p.m. OK Rust 2021 TESTS 15 921 160768000

remove filters

Back to search problems