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.
Problems
There is a graph of (n^2) vertices, where vertices are labeled by integer pairs ((r,c)) such that (1 \le r,c \le n). Vertices ((r_1,c_1)) and ((r_2,c_2)) are directly connected if and only if ((r_1-r_2)^2+(c_1-c_2)^2=\color{red}{13}). This graph is called the Zebra Graph of dimensions (n \times n). Please find a subset of vertices (S) in the Zebra Graph of dimensions (n \times n), which satisfies the following condition. The graph induced(^{\text{∗}}) by the subset (S) is isomorphic to a cycle graph of at least (\left\lfloor{\frac{n^2}{e}}\right\rfloor) vertices(^{\text{†}}). It can be shown that such a subset of vertices exists under the constraints of this problem. (^{\text{∗}})The induced graph of a subset of vertices (X) is a graph that contains all vertices in (X) and all edges whose both endpoints are in (X). (^{\text{†}})Here, (e) is the mathematical constant equal to the limit (\lim \limits_{n \to \infty} \left ({1 + \frac{1}{n}} \right )^n \approx 2.71828182). Note that the value of (\frac{1}{e}) is approximately (0.36787944). The first and only line of input contains a single integer (n) ((n\in \{5,1001\})). There are only two input files for this problem : The first input file (the example input) has (n=5); The second input file has (n=1001). Hacks are disabled for this problem. Output (n) lines, each containing a string (s_i) of length (n) denoting the (i)-th row of the graph. If the vertex ((r,c)) is an element of (S), then the (c)-th letter of (s_r) should be ' 1 '. Otherwise, the (c)-th letter of (s_r) should be ' 0 '. If there are multiple solutions, print any of them. For the example output, the induced graph corresponding to the subset (S) is shown below. This graph is isomorphic to the cycle graph (C_{16}) consisting of (16) vertices. As $$$16 \ge \left\lfloor{\frac{n^2}{e}}\right\rfl |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
364106211 |
lunarlity |
G |
Feb. 23, 2026, 5:41 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
2 |
62 |
9830400 |
|
|
|
364111445 |
Taha90411 |
G |
Feb. 23, 2026, 6:23 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
2 |
453 |
46899200 |
|
|
|
364140071 |
anmol_seth |
G |
Feb. 24, 2026, 1:26 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
2 |
343 |
59699200 |
|
|
|
364102907 |
tourist |
G |
Feb. 23, 2026, 5:02 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
2 |
390 |
59699200 |
|
|
|
364106195 |
ksun48 |
G |
Feb. 23, 2026, 5:41 p.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
2 |
359 |
44236800 |
|
|
|
364152415 |
Dianat2014 |
G |
Feb. 24, 2026, 5:26 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
2 |
359 |
60108800 |
|
|
remove filters
Back to search problems