Codeforces Round 980 (Div. 1)

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
2023 Codeforces Round 980 (Div. 1) FINISHED False 7200 46990523 Oct. 20, 2024, 9:05 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 1369 ) C C+K+S PROGRAMMING brute force constructive algorithms dfs and similar graphs greedy hashing math strings

You are given two strongly connected(^{\dagger}) directed graphs, each with exactly (n) vertices, but possibly different numbers of edges. Upon closer inspection, you noticed an important feature — the length of any cycle in these graphs is divisible by (k). Each of the (2n) vertices belongs to exactly one of two types: incoming or outgoing . For each vertex, its type is known to you. You need to determine whether it is possible to draw exactly (n) directed edges between the source graphs such that the following four conditions are met: The ends of any added edge lie in different graphs. From each outgoing vertex, exactly one added edge originates. Into each incoming vertex, exactly one added edge enters. In the resulting graph, the length of any cycle is divisible by (k). (^{\dagger})A strongly connected graph is a graph in which there is a path from every vertex to every other vertex. Each test consists of multiple test cases. The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The description of the test cases follows. The first line of each test case contains two integers (n) and (k) ((2 \le k \le n \le 2 \cdot 10^5)) — the number of vertices in each graph and the value by which the length of each cycle is divisible. The second line of each test case contains (n) integers (a_1, a_2, \ldots, a_n) ((a_i \in \{0, 1\})). If (a_i = 0), then vertex (i) of the first graph is incoming. If (a_i = 1), then vertex (i) of the first graph is outgoing. The third line of each test case contains a single integer (m_1) ((1 \le m_1 \le 5 \cdot 10^5)) — the number of edges in the first graph. The next (m_1) lines contain descriptions of the edges of the first graph. The (i)-th of them contains two integers (v_i) and (u_i) ((1 \le v_i, u_i \le n)) — an edge in the first graph leading from vertex (v_i) to vertex (u_i). Ne

Tutorials

135341

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
287070082 lddlinan C Oct. 20, 2024, 1:37 p.m. OK C++17 (GCC 7-32) TESTS 28 327 18841600
287002813 OccDreamer C Oct. 20, 2024, 10:39 a.m. OK C++17 (GCC 7-32) TESTS 28 327 60211200
287010192 shao0320 C Oct. 20, 2024, 10:53 a.m. OK C++17 (GCC 7-32) TESTS 28 342 34099200
287121489 Karuk C Oct. 20, 2024, 8:29 p.m. OK C++17 (GCC 7-32) TESTS 28 343 22835200
287131835 _chroneZ C Oct. 20, 2024, 11:57 p.m. OK C++17 (GCC 7-32) TESTS 28 343 26521600
286986994 NKheyuxiang C Oct. 20, 2024, 10:09 a.m. OK C++17 (GCC 7-32) TESTS 28 343 37171200
286996339 wutongchun C Oct. 20, 2024, 10:26 a.m. OK C++17 (GCC 7-32) TESTS 28 343 61849600
287149253 flashmt C Oct. 21, 2024, 5:20 a.m. OK C++17 (GCC 7-32) TESTS 28 358 12595200
287007718 Romy67 C Oct. 20, 2024, 10:49 a.m. OK C++17 (GCC 7-32) TESTS 28 358 25292800
286998134 paulzrm C Oct. 20, 2024, 10:29 a.m. OK C++17 (GCC 7-32) TESTS 28 374 20992000
286929444 maspy C Oct. 20, 2024, 9:31 a.m. OK C++20 (GCC 13-64) TESTS 28 124 10649600
286994102 MtSaka C Oct. 20, 2024, 10:22 a.m. OK C++20 (GCC 13-64) TESTS 28 156 25292800
286967771 Sulfox C Oct. 20, 2024, 9:51 a.m. OK C++20 (GCC 13-64) TESTS 28 171 48844800
287007620 Zhouershan C Oct. 20, 2024, 10:48 a.m. OK C++20 (GCC 13-64) TESTS 28 202 115609600
286993499 8Conan8 C Oct. 20, 2024, 10:20 a.m. OK C++20 (GCC 13-64) TESTS 28 233 28160000
287141998 remake_xhgua C Oct. 21, 2024, 3:41 a.m. OK C++20 (GCC 13-64) TESTS 28 249 29593600
287010912 beautybang C Oct. 20, 2024, 10:55 a.m. OK C++20 (GCC 13-64) TESTS 28 249 46796800
286991905 noya2 C Oct. 20, 2024, 10:17 a.m. OK C++20 (GCC 13-64) TESTS 28 264 9728000
286961847 xuanxuan001 C Oct. 20, 2024, 9:49 a.m. OK C++20 (GCC 13-64) TESTS 28 264 22835200
287134185 fishcathu. C Oct. 21, 2024, 1:02 a.m. OK C++20 (GCC 13-64) TESTS 28 265 1843200
287014674 cmk666 C Oct. 20, 2024, 11:02 a.m. OK C++23 (GCC 14-64, msys2) TESTS 28 124 30515200
286994990 Mtaylor C Oct. 20, 2024, 10:23 a.m. OK C++23 (GCC 14-64, msys2) TESTS 28 265 52019200
287075752 shungszhsch C Oct. 20, 2024, 2:16 p.m. OK C++23 (GCC 14-64, msys2) TESTS 28 265 62464000
286987760 wery0 C Oct. 20, 2024, 10:10 a.m. OK C++23 (GCC 14-64, msys2) TESTS 28 311 23449600
287130829 zfs732 C Oct. 20, 2024, 11:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 28 312 36556800
287029984 __Watcher C Oct. 20, 2024, noon OK C++23 (GCC 14-64, msys2) TESTS 28 327 40140800
287009124 Ranger_CW C Oct. 20, 2024, 10:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 28 343 43520000
287008585 irkstepanov C Oct. 20, 2024, 10:50 a.m. OK C++23 (GCC 14-64, msys2) TESTS 28 358 26316800
287014009 Pablo-No C Oct. 20, 2024, 11 a.m. OK C++23 (GCC 14-64, msys2) TESTS 28 358 50585600
287013042 The_Hallak C Oct. 20, 2024, 10:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 28 358 74649600
286998218 KumaTachiRen C Oct. 20, 2024, 10:30 a.m. OK C# 8 TESTS 28 765 78745600
286928606 hos.lyric C Oct. 20, 2024, 9:30 a.m. OK D TESTS 28 733 41472000
287067114 yvbf C Oct. 20, 2024, 1:17 p.m. OK Java 8 TESTS 28 639 40345600
286970129 toam C Oct. 20, 2024, 9:52 a.m. OK PyPy 3-64 TESTS 28 530 67379200
286933793 chinerist C Oct. 20, 2024, 9:37 a.m. OK PyPy 3-64 TESTS 28 593 66048000
287000320 dyppp C Oct. 20, 2024, 10:34 a.m. OK PyPy 3-64 TESTS 28 734 89600000
287000084 golomb C Oct. 20, 2024, 10:33 a.m. OK PyPy 3-64 TESTS 28 1593 83865600
286974057 mees C Oct. 20, 2024, 9:58 a.m. OK PyPy 3-64 TESTS 28 1780 128102400
286946195 sansen C Oct. 20, 2024, 9:44 a.m. OK Rust 2021 TESTS 28 249 72601600

remove filters

Back to search problems