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
B'This is an interactive problem. You are given an integer n . The jury has hidden from you a directed graph with n vertices (numbered from 1 to n ) and some number of edges. You additionally know that: You want to color each vertex in either black or white such that for any two vertices i and j ( 1 <= i < j <= n ) of the same color, vertex i is reachable from vertex j . To do that, you can ask queries of the following type: Find any valid vertex coloring of the hidden graph in at most 2 cdot n queries. It can be proven that such a coloring always exists. Note that the grader is not adaptive: the graph is fixed before any queries are made. ^ dagger Vertex a is reachable from vertex b if there exists a path from vertex b to vertex a in the graph. Each test contains multiple test cases. The first line of input contains a single integer t ( 1 <= t <= 1000 ) -- the number of test cases. The description of the test cases follows. The only line of each test case contains a single integer n ( 3 <= n <= 100 ) -- the number of vertices in the hidden graph. It is guaranteed that the sum of n over all test cases does not exceed 1000 . The interaction for each test case begins by reading the integer n . To make a query, output "? i j" without quotes ( 1 <= i < j <= n ). If vertex i is reachable from vertex j , you will get YES as an answer. Otherwise, you will get NO as an answer. If you receive the integer -1 instead of an answer or a valid value of n , it means your program has made an invalid query, has exceeded the limit of queries, or has given an incorrect answer on the previous test case. Your program must terminate immediately to receive a Wrong Answer verdict. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream. When you are ready to give the fin'... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
263239834 |
bunH2O |
E |
May 30, 2024, 12:06 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
62 |
1638400 |
|
2600 |
263556985 |
fydj |
E |
May 31, 2024, 11:38 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263506829 |
Rex_Lapis |
E |
May 31, 2024, 1:45 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263154070 |
OMEGAftw |
E |
May 29, 2024, 2:13 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263038074 |
kgkgkgkg |
E |
May 28, 2024, 4:13 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263009957 |
Ethan104 |
E |
May 28, 2024, 12:28 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
262965230 |
ERoslon |
E |
May 28, 2024, 6:08 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263080305 |
45645A |
E |
May 29, 2024, 3:07 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
77 |
102400 |
|
2600 |
262991323 |
ciuim |
E |
May 28, 2024, 9:54 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
77 |
4812800 |
|
2600 |
263176372 |
ritik_2408 |
E |
May 29, 2024, 6:37 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
0 |
|
2600 |
263207208 |
arman_ferdous |
E |
May 30, 2024, 7:02 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
62 |
0 |
|
2600 |
263160079 |
passwordisa |
E |
May 29, 2024, 3:04 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
62 |
0 |
|
2600 |
263073366 |
theRealChainman |
E |
May 29, 2024, 12:38 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
62 |
102400 |
|
2600 |
263696944 |
kinoud |
E |
June 2, 2024, 4 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263668641 |
fryingduc |
E |
June 1, 2024, 6:14 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263593315 |
dumb_boi |
E |
June 1, 2024, 7:42 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263372574 |
Israelis |
E |
May 30, 2024, 5:59 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263371009 |
alvingogo |
E |
May 30, 2024, 5:46 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263367215 |
tingpeng1055 |
E |
May 30, 2024, 5:15 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263366291 |
tingpeng1055 |
E |
May 30, 2024, 5:09 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
77 |
0 |
|
2600 |
263613950 |
rookiefyq |
E |
June 1, 2024, 10:34 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
0 |
|
2600 |
263075116 |
Edlue |
E |
May 29, 2024, 1:23 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
0 |
|
2600 |
263057172 |
jamesbamber |
E |
May 28, 2024, 7:12 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
0 |
|
2600 |
263524930 |
yasseinhamdy15 |
E |
May 31, 2024, 4:17 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
102400 |
|
2600 |
263514633 |
jhdonghj112 |
E |
May 31, 2024, 2:48 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
102400 |
|
2600 |
263393216 |
mario.locaus |
E |
May 30, 2024, 11:36 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
102400 |
|
2600 |
263380309 |
Al27700 |
E |
May 30, 2024, 7:21 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
102400 |
|
2600 |
263102171 |
lqh2024 |
E |
May 29, 2024, 7:18 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
102400 |
|
2600 |
262972945 |
yshpdyt |
E |
May 28, 2024, 7:16 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
2457600 |
|
2600 |
262981712 |
AhmetKaan |
E |
May 28, 2024, 8:31 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
7987200 |
|
2600 |
263175222 |
hasanulhaque |
E |
May 29, 2024, 6:17 p.m. |
OK |
GNU C11 |
TESTS |
29 |
139 |
8396800 |
|
2600 |
263622710 |
nguyenquocthao00 |
E |
June 1, 2024, 11:38 a.m. |
OK |
Go |
TESTS |
29 |
93 |
204800 |
|
2600 |
263232447 |
Dheerajjha |
E |
May 30, 2024, 11:45 a.m. |
OK |
Java 21 |
TESTS |
29 |
374 |
1024000 |
|
2600 |
262970155 |
dzhi |
E |
May 28, 2024, 6:52 a.m. |
OK |
Java 21 |
TESTS |
29 |
436 |
1228800 |
|
2600 |
263198099 |
leelarishika |
E |
May 30, 2024, 4:20 a.m. |
OK |
Java 8 |
TESTS |
29 |
233 |
0 |
|
2600 |
263168807 |
1091857051 |
E |
May 29, 2024, 4:39 p.m. |
OK |
Java 8 |
TESTS |
29 |
234 |
0 |
|
2600 |
263047486 |
strashila |
E |
May 28, 2024, 5:37 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
171 |
2150400 |
|
2600 |
263602789 |
MAO1112 |
E |
June 1, 2024, 8:59 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
234 |
6348800 |
|
2600 |
263160283 |
endlessSecond |
E |
May 29, 2024, 3:06 p.m. |
OK |
Python 3 |
TESTS |
29 |
109 |
0 |
|
2600 |
262971570 |
2210080018 |
E |
May 28, 2024, 7:04 a.m. |
OK |
Python 3 |
TESTS |
29 |
109 |
0 |
|
2600 |
263512301 |
Abed_Alrhman_Alm7sere |
E |
May 31, 2024, 2:29 p.m. |
OK |
Python 3 |
TESTS |
29 |
124 |
0 |
|
2600 |
263258408 |
tarqulalamopi |
E |
May 30, 2024, 1:49 p.m. |
OK |
Python 3 |
TESTS |
29 |
124 |
0 |
|
2600 |
263219143 |
tarqulalamopi |
E |
May 30, 2024, 9:58 a.m. |
OK |
Python 3 |
TESTS |
29 |
124 |
0 |
|
2600 |
263217610 |
endlessSecond |
E |
May 30, 2024, 9:38 a.m. |
OK |
Python 3 |
TESTS |
29 |
140 |
0 |
|
2600 |
remove filters
Back to search problems