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 |
|---|---|---|---|---|---|---|
| 2245 | Spectral::Cup 2026 Round 3 (Codeforces Round 1110, Div. 1 + Div. 2) | FINISHED | False | 9000 | 2387684 | July 16, 2026, 2:45 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 64 ) | H | Connect Connect See | PROGRAMMING | brute force data structures |
You are given a rectangular grid (a) consisting of (n) rows and (m) columns. The (j)-th cell in the (i)-th row is denoted by ((i,j)). There is a non-negative integer written in every cell. The integer written in cell ((i,j)) is denoted by (a_{i,j}). A path (p) of length (k) on (a) is defined as a sequence of cells (p_0,p_1,\ldots,p_k) such that (p_i) and (p_{i+1}) share an edge for every (0 \le i \lt k), and all (p_i) are distinct. The number of turns of a simple path (p) of length (k), denoted by (t(p)), is defined as the number of indices (1 \le i \lt k) that satisfy the following condition: Let (p_j=(x_j,y_j)) for (j \in \{i-1,i,i+1\}). Then, both (x_{i-1} \ne x_{i+1}) and (y_{i-1} \ne y_{i+1}) hold. A path (p=(x_0,y_0),(x_1,y_1),\ldots,(x_k,y_k)) is considered valid if and only if all of the following conditions hold: (k \ge 1). (t(p) \le 2). (a_{x_0,y_0}=a_{x_k,y_k}), (a_{x_0,y_0} \gt 0), and (a_{x_i,y_i}=0) for every (1 \le i \lt k). An unordered pair of cells ((u_1,v_1)) and ((u_2,v_2)) is considered connectable if and only if there exists a valid path (p) of length (k) such that (p_0=(u_1,v_1)) and (p_k=(u_2,v_2)). Find the number of connectable pairs in (a). Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each test case contains two integers (n) and (m) ((1 \le n \le 100), (1 \le n \cdot m \le 2 \cdot 10^6)), representing the dimensions of (a). The (i)-th of the next (n) lines contains (m) integers (a_{i,1}, a_{i,2},\ldots,a_{i,m}) ((0 \le a_{i,j} \le n \cdot m)), representing the (i)-th row of (a). It is guaranteed that the sum of (n \cdot m) over all test cases does not exceed (2 \cdot 10^6). For each test |
| Spectral::Cup 2026 Round 3 (Codeforces Round 1110, Div. 1 + Div. 2) Editorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 383028762 | aslam_45 | H | July 16, 2026, 7:10 p.m. | OK | C++17 (GCC 7-32) | TESTS | 80 | 2406 | 265728000 | ||
| 383019535 | Dedei | H | July 16, 2026, 5:49 p.m. | OK | C++17 (GCC 7-32) | TESTS | 80 | 2406 | 265830400 | ||
| 383016775 | rnzhemvhtm | H | July 16, 2026, 5:29 p.m. | OK | C++17 (GCC 7-32) | TESTS | 80 | 2406 | 265830400 | ||
| 383062573 | didxga | H | July 17, 2026, 4:02 a.m. | OK | C++17 (GCC 7-32) | TESTS | 80 | 2484 | 113459200 | ||
| 383054199 | sunyata258 | H | July 17, 2026, 2:03 a.m. | OK | C++17 (GCC 7-32) | TESTS | 80 | 3671 | 213913600 | ||
| 383034646 | atg_07 | H | July 16, 2026, 8:11 p.m. | OK | C++17 (GCC 7-32) | TESTS | 80 | 3921 | 216064000 | ||
| 383027426 | iwannadothismoreandmore | H | July 16, 2026, 6:59 p.m. | OK | C++17 (GCC 7-32) | TESTS | 80 | 5234 | 229683200 | ||
| 383021089 | Asv1411 | H | July 16, 2026, 6:01 p.m. | OK | C++20 (GCC 13-64) | TESTS | 80 | 2875 | 210432000 | ||
| 383026590 | TangZiFan | H | July 16, 2026, 6:50 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 80 | 1703 | 99942400 | ||
| 383067964 | felix07 | H | July 17, 2026, 5:15 a.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 80 | 2062 | 212377600 | ||
| 383024661 | Andy | H | July 16, 2026, 6:30 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 80 | 2953 | 163532800 | ||
| 383020354 | ankitraj803120 | H | July 16, 2026, 5:55 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 80 | 3500 | 224460800 | ||
| 383039434 | vangoat | H | July 16, 2026, 8:59 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 80 | 4390 | 166195200 | ||
| 383023771 | beaaaan | H | July 16, 2026, 6:23 p.m. | OK | C++23 (GCC 14-64, msys2) | TESTS | 80 | 6968 | 522240000 | ||
| 383017595 | d11maan | H | July 16, 2026, 5:34 p.m. | OK | Rust 2024 | TESTS | 80 | 3406 | 161996800 |
Back to search problems