Update dataset
Browse files- README.md +2 -2
- data/test-00000-of-00001.json +2 -1
README.md
CHANGED
|
@@ -19,8 +19,8 @@ A benchmark dataset for evaluating AI systems on challenging computer science pr
|
|
| 19 |
|
| 20 |
## Dataset Description
|
| 21 |
|
| 22 |
-
This dataset contains
|
| 23 |
-
- **Algorithmic**:
|
| 24 |
- **Research**: 63 open-ended research problems
|
| 25 |
|
| 26 |
## Dataset Structure
|
|
|
|
| 19 |
|
| 20 |
## Dataset Description
|
| 21 |
|
| 22 |
+
This dataset contains 205 problems across two categories:
|
| 23 |
+
- **Algorithmic**: 142 competitive programming problems with automated judging
|
| 24 |
- **Research**: 63 open-ended research problems
|
| 25 |
|
| 26 |
## Dataset Structure
|
data/test-00000-of-00001.json
CHANGED
|
@@ -109,7 +109,8 @@
|
|
| 109 |
{"problem_id": "5", "category": "algorithmic", "statement": "Problem: Hamiltonian Path Challenge\n\nYou are given a directed graph with n vertices and m edges. \nYour task is to find a path that visits each vertex exactly once. \n\nIf it is not possible to find a Hamiltonian path, you should instead output a path that is as long as possible and does not repeat vertices. \n\n----------------------------------------\nInput\nThe first line contains two integers n, m. \nThe second line contains 10 integers, where the i-th number is a_i, the scoring parameter. \nEach of the next m lines contains two integers u, v, representing a directed edge from u to v.\n\n----------------------------------------\nOutput\nOutput two lines:\n\n- The first line contains an integer k, the number of vertices in your path. \n- The second line contains k integers, the sequence of vertices in the path.\n\n----------------------------------------\nSample 1\nInput:\n3 3\n3 3 3 3 3 3 3 3 3 3\n1 2\n1 3\n2 3\n\nOutput:\n3\n1 2 3\n\nExplanation:\nEdges are directed. \nIn this case, the contestant’s submission scores 10 points.\n\n----------------------------------------\nSample 2\nInput:\n4 4\n1 1 2 2 3 3 4 4 4 4\n1 2\n2 1\n1 3\n4 2\n\nOutput:\n2\n2 1\n\nExplanation:\nIn this case, the submission scores 4 points. \nNote: you do not need to output the optimal solution.\n\n----------------------------------------\nScoring\n- If your output is invalid, your score is 0. \n- Otherwise, let k be the number of vertices in your path. \n Your score is equal to: \n\n sum_{i=1}^{10} [k ≥ a_i] \n\nThat is, the number of a_i values that are less than or equal to your k.\n\n----------------------------------------\nConstraints\n- 1 ≤ n, m ≤ 500000 \n- No multiple edges, no self-loops \n- At least one Hamiltonian path exists in the graph\n\n----------------------------------------\nTime Limit: 4 second \nMemory Limit: 512 MB", "config": "type: default\n\ntime: 4s\nmemory: 512m\n\nchecker: chk.cc\ncheker_type: SPJ\nsubtasks:\n - score: 100\n n_cases: 3"}
|
| 110 |
{"problem_id": "50", "category": "algorithmic", "statement": "Time Limit: 10s\nMemory Limit: 1024M\n\nFirstly, you are given two integers n (1 <= n <= 400) and m (1 <= m <= 4000), which means that you have n elements and m sets.\n\nAfter that, there are m integers, the i-th integer is the cost of choosing the i-th set.\n\nAfter that, for the i-th element, firstly input an integer k_i, which means the number of sets that contain the element. After that, there\n\nare k_i integers, the j-th integer a_j means that the set with id a_j contains the element i.\n\nFind some sets so that each element belongs to at least one of these sets. You need to minimize the total cost of these sets. This value will determine your final score.\n\nOutput: \n\nFirstly output an integer |S|, which means the number of sets you choose. After that, output |S| ids of the sets you choose in another line.\n\n", "config": "type: default\ntime: 10s\nmemory: 1024m\nsubtasks:\n - score: 100\n n_cases: 3\nchecker: chk.cc\nchecker_type: testlib\nfilename: std.cc"}
|
| 111 |
{"problem_id": "52", "category": "algorithmic", "statement": "Geemu\n\nThis is an interactive problem.\n\nLittle A has an interesting game.\nInitially, there is a permutation p of length n. You don't know the permutation p, and you need to determine the final p through the following operations:\n1. Query the number of value-contiguous segments in a given interval.\n2. Swap two elements at given positions.\n\nSmart little B discovered that no matter what you do, there are always two permutations p that cannot be distinguished. For convenience, you only need to find one of the possible permutations p.\nLet s_1 be the number of times you use operation 1, and s_2 be the number of times you use operation 2.\n\nInput\nThere is only one test case in each test file.\nThe first line of the input contains three integers n, l_1, and l_2 (1 ≤ n ≤ 10^3, 1 ≤ l_1, l_2 ≤ 10^5) indicating the length of the hidden permutation, the maximum allowed number of ask operations, and the maximum allowed number of swap operations.\n\nInteraction\nTo query the number of value-contiguous segments in an interval [l, r], output one line:\n 1 l r\nwhere 1 ≤ l ≤ r ≤ n.\nAfter flushing your output, read one integer x indicating the number of value-contiguous segments in the interval [l, r].\nTo swap two elements at positions i and j, output one line:\n 2 i j\nwhere 1 ≤ i, j ≤ n.\nAfter flushing your output, read the integer 1 to confirm the swap was performed.\nTo submit your final answer, output one line:\n 3 p_1 p_2 ... p_n\nwhere p_1, p_2, ..., p_n is your determined permutation.\nAfter submitting your report, your program should exit immediately.\nTo flush your output, you can use:\n fflush(stdout) (if you use printf) or cout.flush() (if you use cout) in C and C++.\n System.out.flush() in Java.\n stdout.flush() in Python.\n\nScoring\nYour solution will be scored based on the efficiency of your queries and swaps, with limits l_1 for operation 1 and l_2 for operation 2.\nLet s_1 be the number of queries (operation 1) you use, and s_2 be the number of swaps (operation 2) you use.\nLet r_1 be the number of queries (operation 1) the reference solution uses, and r_2 be the number of swaps (operation 2) the reference solution uses.\nYour score for each test case is calculated as follows:\n1. If s_1 > l_1 or s_2 > l_2, you receive 0 points for that test case.\n2. Otherwise, your score for this test case is calculated as:\n score = 100 * min((r_1 + r_2 + 1) / (s_1 + s_2 + 1), 1)\nYour final score is the average of your scores across all test cases.\n\nTime limit: 2 seconds\nMemoriy limit: 512 MB\n\nExample input:\n\n1 1 2\n\n1 1 3\n\n1 2 3\n\n1 1 3\n\n1 2 4\n\n1 1 4\n\n1 2 5\n\n1 3 5\n\n1 4 5\n\n1 2 5\n\n1 1 5\n\n3 3 5 4 1 2 \n\nExample output:\n5 100 50\n\n2\n\n1\n\n1\n\n1\n\n2\n\n2\n\n2\n\n2\n\n1\n\n2\n\n1", "config": "type: interactive\n\ninteractor: interactor.cc\n\ntime: 2s\nmemory: 512m\n\nsubtasks:\n - score: 100\n n_cases: 3"}
|
| 112 |
-
{"problem_id": "53", "category": "algorithmic", "statement": "Problem: G2. Inter Active (Hard Version)\n\nTime limit: 2 seconds\n\nMemory limit: 512 MB\n\nThis is the hard version of the problem. The difference between the versions is that in this version, you can make at most 10 * n queries. You can hack only if you solved all versions of this problem.\n\nAli loved Bahamin's gift (from problem E) so much that he illegally traveled from Qazvin to Liverpool to have the gift signed by football players. Now Interpol is searching for him, but they've offered a deal: solve a problem, and he can stay in Liverpool. But since he's currently at the stadium, he can't solve it so he asked you to do it.\n\nThis is an interactive problem.\n\nThere is a hidden permutation p of length n >= 4 where p_i != i for each 1 <= i <= n.\n\nInitially, you should give the jury a positive integer k <= n, which will be constant through future queries.\n\nThen you need to find permutation p using some queries.\n\nIn each query, you give a permutation q_1, q_2, ..., q_n to the jury. In response, you will receive the number of pairs (i, j) such that all of the following conditions hold:\n- i < j\n- p_{q_i} = q_j\n- i != k (k is the constant you have given to the jury)\n\nYou are given n, and you need to find the permutation p in at most 10 * n queries.\n\nA permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array), and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\n\nInput\n\nEach test contains multiple test cases. The first line contains the number of test cases t (1 <= t <= 500). The description of the test cases follows.\n\nThe only line of each test case contains a single integer n (4 <= n <= 100) — the length of p.\n\nIt is guaranteed that the sum of n^2 over all test cases does not exceed 10^4.\n\nInteraction Protocol\n\nThe interaction for each test case begins with reading the integer n.\n\nThen you should output the integer k (1 <= k <= n). This is not considered as a query.\n\nThen you can ask up to 10 * n queries. To make a query, output a line in the following format:\n? q_1 q_2 ... q_n\n\nThe jury will return the answer to the query.\n\nWhen you find the permutation p, output a single line in the following format:\n! p_1 p_2 ... p_n\n\nThis is also not considered as a query.\n\nAfter that, proceed to process the next test case or terminate the program if it is the last test case.\n\nThe interactor is not adaptive, which means that the permutation is determined before the participant outputs k.\n\nIf your program makes more than 10 * n queries, your program should immediately terminate to receive the verdict Wrong answer. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.\n\nAfter printing each query do not forget to output the end of line and flush the output. Otherwise, you will get Idleness limit exceeded verdict.\n\nIf, at any interaction step, you read -1 instead of valid data, your solution must exit immediately.\n\nNote:\nIn the first test case, p=[3,1,4,2]. The solution selected k=1 then it asked permutation q=[1,2,3,4]. Only pair (3,4) satisfies the conditions.\nIn the second test case, p=[3,1,2,5,4]. The solution selected k=3. For permutation q=[1,2,5,4,3], only pair (1,5) satisfies the conditions. For permutation q=[2,1,4,3,5], pairs (1,2) and (2, 4) satisfy the conditions.\n\nExample Input:\n2\n4\n1\n\n5\n1\n2\n\nExample Output:\n1\n? 1 2 3 4\n! 3 1 4 2\n3\n? 1 2 5 4 3\n? 2 1 4 3 5\n! 3 1 2 5 4", "config": "# Set the problem type to interactive\ntype: interactive\n\n# Specify the interactor source file\ninteractor: interactor.cc\n\n# Time and memory limits still apply to the contestant's solution\ntime: 2s\nmemory: 512m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases:
|
|
|
|
| 113 |
{"problem_id": "57", "category": "algorithmic", "statement": "time limit per test: 5 seconds\nmemory limit per test: 1024 megabytes\n**Submissions are only allowed in C++ language.**\n\n\nThis problem is interactive.\n\nBaudelaire is very rich, so he bought a tree of size n, rooted at some arbitrary node. Additionally,\nevery node has a value of 1 or -1.\n\nCow the Nerd saw the tree and fell in love with it. However, computer science doesn't pay him\nenough, so he can't afford to buy it. Baudelaire decided to play a game with Cow the Nerd, and if\nhe won, he would gift him the tree.\n\nCow the Nerd does not know which node is the root, and he doesn't know the values of the nodes\neither. However, he can ask Baudelaire queries of two types:\n\nType 1 query: Let f(u) be the sum of the values of all nodes in the path from the root of\nthe tree to node u. Cow the Nerd may choose an integer k and k nodes u1,u2,...,uk,\nand he will receive the value f(u1)+f(u2)+...+f(uk).\n\nTo ask this query, print:\n? 1 k u1 u2 ... uk\nand read an integer from the interactor.\n\nType 2 query: Baudelaire will toggle the value of node u. Specifically, if the value of u is 1, it will\nbecome -1, and vice versa.\n\nTo ask this query, print:\n? 2 u\nand read the response (no output, just toggle).\n\nCow the Nerd wins if he guesses the value of every node correctly (the values of the final tree,\nafter performing the queries) within Q total queries. Can you help him win?\n\nScoring\nIf your solution makes at most n queries, you will receive 100 points.\nIf it makes more than n+1000 queries, you will receive 0 points.\nIf it makes x queries where n < x ≤ n+1000, your score will be linearly interpolated\nfrom 100 down to 0.\n\nInput\nThe first line of the input contains a single integer t (1 ≤ t ≤ 100), the number of test cases.\n\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 1000), the size of the tree.\n\nEach of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v),\ndenoting an edge between nodes u and v in the tree.\n\nIt is guaranteed that the sum of n over all test cases does not exceed 1000 and that each graph\nprovided is a valid tree.\n\nInteraction\nAfter printing a query do not forget to output the end of line and flush the output. Otherwise, you\nmay get the Idleness Limit Exceeded verdict.\n\nWhen you have found the answer, output:\n! v1 v2 ... vn\nwhere vi is the value of node i after performing the queries.\n\nPrinting the answer does not count as a query.\n\nExample\n\ninput\n3\n4\n1 4\n4 2\n2 3\n1\n-1\n-5\n-5\n2\n1 2\n2\n7\n1 2\n2 7\n7 3\n7 4\n7 5\n7 6\n-1\n\noutput\n? 1 3 1 2 4\n? 1 2 3 1\n? 2 4\n? 1 3 1 2 4\n? 1 2 3 1\n! -1 -1 -1 -1\n? 1 1 1\n! -1 1 1 1 1 1 -1", "config": "# Set the problem type to interactive\ntype: interactive\n\n# Specify the interactor source file\ninteractor: interactor.cpp\n\n# Time and memory limits still apply to the contestant's solution\ntime: 5s\nmemory: 1024m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 3 # Looks for 1.in, 2.in, ... 5.in"}
|
| 114 |
{"problem_id": "58", "category": "algorithmic", "statement": "Inverse Counting Path\n\nWalk Alone is an expert in dynamic programming, but he gets bored with traditional dynamic programming problem like counting paths on a 2-dimension grid, so he wants to do it in reverse. The problem he raised is as follows:\n\nOn a 2-dimension grid of size n*n, originally you are on grid (1,1). The grid consists of 0 and 1, and you can only walk on the grid with number 1 in it. You can only go down or right, i.e. you can only increase your x or y by one. Also you cannot walk outside the grid.\n\nGiven the number x of ways to walk from (1,1) to (n,n), you need to construct a grid of n*n so that the ways to walk is exactly x. However, since Walk Alone's brain is too small to memorize such a big grid, you need to guarantee that the size of the grid n is equal to or smaller than 300. Specifically, your score will be (300 - n) / 300.\n\nInput\n\nThe only line of the input contains one integer x (1<=x<=10^18), denoting the ways to walk.\n\nOutput\n\nThe first line of the output contains the size of the grid n. Remind that you need to guarantee 1<=n<=300.\n\nThe following n lines each contains n integers a_{i,j}∈{0,1} denoting the grid, where 0 denotes you cannot walk on the grid while 1 is on the contrast.\n\nExample Input 1:\n\n3\n\nExample Output 1:\n\n3\n1 1 0\n1 1 0\n1 1 1\n\nExample Input 2:\n\n10\n\nExample Output 2:\n\n4\n1 1 1 0\n1 1 1 1\n1 0 1 1\n1 1 1 1", "config": "# Set the problem type to interactive\ntype: default\n\n# Specify the interactor source file\ninteractor: chk.cc\n\n# Time and memory limits still apply to the contestant's solution\ntime: 1s\nmemory: 512m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 3 # Looks for 1.in, 2.in, ... 5.in"}
|
| 115 |
{"problem_id": "59", "category": "algorithmic", "statement": "# Limited Shuffle Restoring\n\n**Input file:** standard input \n**Output file:** standard output \n**Time limit:** 3 seconds \n**Memory limit:** 512 meblbytes \n\n**This is an interactive problem.**\n\nBobo had an array \\\\( a \\\\), initially equal to \\\\((1,2,\\ldots,n)\\\\). He did the following operations with the array.\n\n- For each \\\\( i \\\\) from 1 to \\\\( n \\\\) in this order, Bobo picked some index \\\\( j \\\\) such that \\\\( i \\leq j \\leq \\min(n,i+2) \\\\), and swapped \\\\( a_i \\\\) and \\\\( a_j \\\\). Of course, if \\\\( i = j \\\\), then nothing happened after the operation.\n\nYour goal is to determine the final array. You may ask questions of the following type.\n\n- ? i j meaning the question \"How do \\\\( a_i \\\\) and \\\\( a_j \\\\) compare to each other?\". Bobo will respond to this with one symbol < or >, meaning that \\\\( a_i < a_j \\\\) or \\\\( a_i > a_j \\\\), respectively.\n\nYou may ask no more than \\\\(\\lfloor 5n/3 \\rfloor + 5\\\\) questions. After this, you must guess the array.\n\n## Interaction Protocol\n\nFirst, the interactor prints the number \\\\( n \\\\) in a separate line (\\\\( 1 \\leq n \\leq 30,000 \\\\)). Then the solution makes queries, where each query consists of printing ? i j on a separate line, where \\\\( 1 \\leq i,j \\leq n \\\\), and \\\\( i \\neq j \\\\). After each query the interactor prints one character < or > on a separate line.\n\nAfter the solution has finished asking questions, it must make a guess. If you think that the array is \\\\((a_1,\\ldots,a_n)\\\\), print ! \\\\( a_1 \\ a_2 \\ldots \\ a_n \\\\) on a separate line and terminate.\n\nIf your solution makes more than \\\\(\\lfloor 5n/3 \\rfloor + 5\\\\) queries, the interactor will finish with the WA verdict. If you do not flush the output after printing a query, you may receive the IL verdict.\n\nNote that the interactor in this task is **adaptive**, i.e. the array may be generated at the runtime consistently with your questions.\n\n## Example\n\n| standard input | standard output |\n|----------------|-----------------|\n| 5 | ? 5 4 |\n| < | ? 5 1 |\n| > | ? 5 3 |\n| > | ? 3 1 |\n| < | ? 2 1 |\n| > | ? 5 2 |\n| > | ! 2 3 1 5 4 |", "config": "type: interactive\n\ntime: 3s\nmemory: 512m\n\ninteractor: interactor.cpp\ninteractor_type: testlib\n\nsubtasks:\n - score: 100\n n_cases: 3"}
|
|
|
|
| 109 |
{"problem_id": "5", "category": "algorithmic", "statement": "Problem: Hamiltonian Path Challenge\n\nYou are given a directed graph with n vertices and m edges. \nYour task is to find a path that visits each vertex exactly once. \n\nIf it is not possible to find a Hamiltonian path, you should instead output a path that is as long as possible and does not repeat vertices. \n\n----------------------------------------\nInput\nThe first line contains two integers n, m. \nThe second line contains 10 integers, where the i-th number is a_i, the scoring parameter. \nEach of the next m lines contains two integers u, v, representing a directed edge from u to v.\n\n----------------------------------------\nOutput\nOutput two lines:\n\n- The first line contains an integer k, the number of vertices in your path. \n- The second line contains k integers, the sequence of vertices in the path.\n\n----------------------------------------\nSample 1\nInput:\n3 3\n3 3 3 3 3 3 3 3 3 3\n1 2\n1 3\n2 3\n\nOutput:\n3\n1 2 3\n\nExplanation:\nEdges are directed. \nIn this case, the contestant’s submission scores 10 points.\n\n----------------------------------------\nSample 2\nInput:\n4 4\n1 1 2 2 3 3 4 4 4 4\n1 2\n2 1\n1 3\n4 2\n\nOutput:\n2\n2 1\n\nExplanation:\nIn this case, the submission scores 4 points. \nNote: you do not need to output the optimal solution.\n\n----------------------------------------\nScoring\n- If your output is invalid, your score is 0. \n- Otherwise, let k be the number of vertices in your path. \n Your score is equal to: \n\n sum_{i=1}^{10} [k ≥ a_i] \n\nThat is, the number of a_i values that are less than or equal to your k.\n\n----------------------------------------\nConstraints\n- 1 ≤ n, m ≤ 500000 \n- No multiple edges, no self-loops \n- At least one Hamiltonian path exists in the graph\n\n----------------------------------------\nTime Limit: 4 second \nMemory Limit: 512 MB", "config": "type: default\n\ntime: 4s\nmemory: 512m\n\nchecker: chk.cc\ncheker_type: SPJ\nsubtasks:\n - score: 100\n n_cases: 3"}
|
| 110 |
{"problem_id": "50", "category": "algorithmic", "statement": "Time Limit: 10s\nMemory Limit: 1024M\n\nFirstly, you are given two integers n (1 <= n <= 400) and m (1 <= m <= 4000), which means that you have n elements and m sets.\n\nAfter that, there are m integers, the i-th integer is the cost of choosing the i-th set.\n\nAfter that, for the i-th element, firstly input an integer k_i, which means the number of sets that contain the element. After that, there\n\nare k_i integers, the j-th integer a_j means that the set with id a_j contains the element i.\n\nFind some sets so that each element belongs to at least one of these sets. You need to minimize the total cost of these sets. This value will determine your final score.\n\nOutput: \n\nFirstly output an integer |S|, which means the number of sets you choose. After that, output |S| ids of the sets you choose in another line.\n\n", "config": "type: default\ntime: 10s\nmemory: 1024m\nsubtasks:\n - score: 100\n n_cases: 3\nchecker: chk.cc\nchecker_type: testlib\nfilename: std.cc"}
|
| 111 |
{"problem_id": "52", "category": "algorithmic", "statement": "Geemu\n\nThis is an interactive problem.\n\nLittle A has an interesting game.\nInitially, there is a permutation p of length n. You don't know the permutation p, and you need to determine the final p through the following operations:\n1. Query the number of value-contiguous segments in a given interval.\n2. Swap two elements at given positions.\n\nSmart little B discovered that no matter what you do, there are always two permutations p that cannot be distinguished. For convenience, you only need to find one of the possible permutations p.\nLet s_1 be the number of times you use operation 1, and s_2 be the number of times you use operation 2.\n\nInput\nThere is only one test case in each test file.\nThe first line of the input contains three integers n, l_1, and l_2 (1 ≤ n ≤ 10^3, 1 ≤ l_1, l_2 ≤ 10^5) indicating the length of the hidden permutation, the maximum allowed number of ask operations, and the maximum allowed number of swap operations.\n\nInteraction\nTo query the number of value-contiguous segments in an interval [l, r], output one line:\n 1 l r\nwhere 1 ≤ l ≤ r ≤ n.\nAfter flushing your output, read one integer x indicating the number of value-contiguous segments in the interval [l, r].\nTo swap two elements at positions i and j, output one line:\n 2 i j\nwhere 1 ≤ i, j ≤ n.\nAfter flushing your output, read the integer 1 to confirm the swap was performed.\nTo submit your final answer, output one line:\n 3 p_1 p_2 ... p_n\nwhere p_1, p_2, ..., p_n is your determined permutation.\nAfter submitting your report, your program should exit immediately.\nTo flush your output, you can use:\n fflush(stdout) (if you use printf) or cout.flush() (if you use cout) in C and C++.\n System.out.flush() in Java.\n stdout.flush() in Python.\n\nScoring\nYour solution will be scored based on the efficiency of your queries and swaps, with limits l_1 for operation 1 and l_2 for operation 2.\nLet s_1 be the number of queries (operation 1) you use, and s_2 be the number of swaps (operation 2) you use.\nLet r_1 be the number of queries (operation 1) the reference solution uses, and r_2 be the number of swaps (operation 2) the reference solution uses.\nYour score for each test case is calculated as follows:\n1. If s_1 > l_1 or s_2 > l_2, you receive 0 points for that test case.\n2. Otherwise, your score for this test case is calculated as:\n score = 100 * min((r_1 + r_2 + 1) / (s_1 + s_2 + 1), 1)\nYour final score is the average of your scores across all test cases.\n\nTime limit: 2 seconds\nMemoriy limit: 512 MB\n\nExample input:\n\n1 1 2\n\n1 1 3\n\n1 2 3\n\n1 1 3\n\n1 2 4\n\n1 1 4\n\n1 2 5\n\n1 3 5\n\n1 4 5\n\n1 2 5\n\n1 1 5\n\n3 3 5 4 1 2 \n\nExample output:\n5 100 50\n\n2\n\n1\n\n1\n\n1\n\n2\n\n2\n\n2\n\n2\n\n1\n\n2\n\n1", "config": "type: interactive\n\ninteractor: interactor.cc\n\ntime: 2s\nmemory: 512m\n\nsubtasks:\n - score: 100\n n_cases: 3"}
|
| 112 |
+
{"problem_id": "53", "category": "algorithmic", "statement": "Problem: G2. Inter Active (Hard Version)\n\nTime limit: 2 seconds\n\nMemory limit: 512 MB\n\nThis is the hard version of the problem. The difference between the versions is that in this version, you can make at most 10 * n queries. You can hack only if you solved all versions of this problem.\n\nAli loved Bahamin's gift (from problem E) so much that he illegally traveled from Qazvin to Liverpool to have the gift signed by football players. Now Interpol is searching for him, but they've offered a deal: solve a problem, and he can stay in Liverpool. But since he's currently at the stadium, he can't solve it so he asked you to do it.\n\nThis is an interactive problem.\n\nThere is a hidden permutation p of length n >= 4 where p_i != i for each 1 <= i <= n.\n\nInitially, you should give the jury a positive integer k <= n, which will be constant through future queries.\n\nThen you need to find permutation p using some queries.\n\nIn each query, you give a permutation q_1, q_2, ..., q_n to the jury. In response, you will receive the number of pairs (i, j) such that all of the following conditions hold:\n- i < j\n- p_{q_i} = q_j\n- i != k (k is the constant you have given to the jury)\n\nYou are given n, and you need to find the permutation p in at most 10 * n queries.\n\nA permutation of length n is an array consisting of n distinct integers from 1 to n in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array), and [1,3,4] is also not a permutation (n=3 but there is 4 in the array).\n\nInput\n\nEach test contains multiple test cases. The first line contains the number of test cases t (1 <= t <= 500). The description of the test cases follows.\n\nThe only line of each test case contains a single integer n (4 <= n <= 100) — the length of p.\n\nIt is guaranteed that the sum of n^2 over all test cases does not exceed 10^4.\n\nInteraction Protocol\n\nThe interaction for each test case begins with reading the integer n.\n\nThen you should output the integer k (1 <= k <= n). This is not considered as a query.\n\nThen you can ask up to 10 * n queries. To make a query, output a line in the following format:\n? q_1 q_2 ... q_n\n\nThe jury will return the answer to the query.\n\nWhen you find the permutation p, output a single line in the following format:\n! p_1 p_2 ... p_n\n\nThis is also not considered as a query.\n\nAfter that, proceed to process the next test case or terminate the program if it is the last test case.\n\nThe interactor is not adaptive, which means that the permutation is determined before the participant outputs k.\n\nIf your program makes more than 10 * n queries, your program should immediately terminate to receive the verdict Wrong answer. Otherwise, you can get an arbitrary verdict because your solution will continue to read from a closed stream.\n\nAfter printing each query do not forget to output the end of line and flush the output. Otherwise, you will get Idleness limit exceeded verdict.\n\nIf, at any interaction step, you read -1 instead of valid data, your solution must exit immediately.\n\nNote:\nIn the first test case, p=[3,1,4,2]. The solution selected k=1 then it asked permutation q=[1,2,3,4]. Only pair (3,4) satisfies the conditions.\nIn the second test case, p=[3,1,2,5,4]. The solution selected k=3. For permutation q=[1,2,5,4,3], only pair (1,5) satisfies the conditions. For permutation q=[2,1,4,3,5], pairs (1,2) and (2, 4) satisfy the conditions.\n\nExample Input:\n2\n4\n1\n\n5\n1\n2\n\nExample Output:\n1\n? 1 2 3 4\n! 3 1 4 2\n3\n? 1 2 5 4 3\n? 2 1 4 3 5\n! 3 1 2 5 4", "config": "# Set the problem type to interactive\ntype: interactive\n\n# Specify the interactor source file\ninteractor: interactor.cc\n\n# Time and memory limits still apply to the contestant's solution\ntime: 2s\nmemory: 512m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 1 # Looks for 1.in, 2.in, ... 5.in"}
|
| 113 |
+
{"problem_id": "54", "category": "algorithmic", "statement": "Problem: Centroid Guess\n\nTime limit: 4 seconds\n\nMemory limit: 512 MB\n\nThis is an interactive problem.\n\nThere is an unknown tree consisting of n nodes, which has exactly one centroid.\nYou only know n at first, and your task is to find the centroid of the tree.\n\nYou can ask the distance between any two vertices. However, making too many queries will reduce your score, and exceeding 400,000 queries will result in 0 points (and potentially a Wrong Answer verdict).\n\nNote that the interactor is not adaptive. That is, the tree is fixed in each test beforehand and does not depend on your queries.\n\nA vertex is called a centroid if its removal splits the tree into subtrees with at most floor(n/2) vertices each.\n\nInput\n\nThe only line of the input contains an integer n (3 <= n <= 7.5 * 10^4) the number of nodes in the tree.\n\nInteraction Protocol\n\nStart interaction by reading n.\n\nTo ask a query about the distance between two nodes u, v (1 <= u, v <= n) output \"? u v\".\n\nIf you determine that the centroid of the tree is x, use \"! x\" to report.\n\nAfter printing a query, do not forget to output the end of a line and flush the output.\nOtherwise, you will get Idleness limit exceeded. To do this, use:\n- fflush(stdout) or cout.flush() in C++;\n- System.out.flush() in Java;\n- flush(output) in Pascal;\n- stdout.flush() in Python;\n- see documentation for other languages.\n\nScoring\n\nYour score depends on the number of queries Q you use to identify the centroid.\n\nLet K_base = 100000 and K_zero = 400000.\n\nThe score is calculated using the following quadratic formula:\nScore = max(0, 100 * ((K_zero - Q) / (K_zero - K_base))^2)\n\nSpecifically:\n- Base Score (100 pts): If you use Q <= 100000 queries, you will receive at least 100 points.\n- Partial Score: If you use between 100000 and 400000 queries, your score will decrease quadratically. For example, using 250000 queries yields 25 points.\n- Zero Score: If you use Q >= 400000 queries, you will receive 0 points.\n- Bonus Score: This problem supports unbounded scoring. If your solution uses fewer than 100000 queries, your score will follow the same curve and exceed 100 points.\n\nHacks are disabled in this problem.\nIt's guaranteed that there are at most 500 tests in this problem.\n\nExample Input:\n5\n\n2\n\n1\n\n2\n\n3\n\n1\n\n1\n\n1\n\nExample Output:\n? 1 2\n\n? 1 3\n\n? 1 4\n\n? 1 5\n\n? 2 3\n\n? 3 4\n\n? 4 5\n\n! 3", "config": "# Set the problem type to interactive\ntype: interactive\n\n# Specify the interactor source file\ninteractor: interactor.cc\n\n# Time and memory limits still apply to the contestant's solution\ntime: 4s\nmemory: 512m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 1 # Looks for 1.in, 2.in, ... 5.in"}
|
| 114 |
{"problem_id": "57", "category": "algorithmic", "statement": "time limit per test: 5 seconds\nmemory limit per test: 1024 megabytes\n**Submissions are only allowed in C++ language.**\n\n\nThis problem is interactive.\n\nBaudelaire is very rich, so he bought a tree of size n, rooted at some arbitrary node. Additionally,\nevery node has a value of 1 or -1.\n\nCow the Nerd saw the tree and fell in love with it. However, computer science doesn't pay him\nenough, so he can't afford to buy it. Baudelaire decided to play a game with Cow the Nerd, and if\nhe won, he would gift him the tree.\n\nCow the Nerd does not know which node is the root, and he doesn't know the values of the nodes\neither. However, he can ask Baudelaire queries of two types:\n\nType 1 query: Let f(u) be the sum of the values of all nodes in the path from the root of\nthe tree to node u. Cow the Nerd may choose an integer k and k nodes u1,u2,...,uk,\nand he will receive the value f(u1)+f(u2)+...+f(uk).\n\nTo ask this query, print:\n? 1 k u1 u2 ... uk\nand read an integer from the interactor.\n\nType 2 query: Baudelaire will toggle the value of node u. Specifically, if the value of u is 1, it will\nbecome -1, and vice versa.\n\nTo ask this query, print:\n? 2 u\nand read the response (no output, just toggle).\n\nCow the Nerd wins if he guesses the value of every node correctly (the values of the final tree,\nafter performing the queries) within Q total queries. Can you help him win?\n\nScoring\nIf your solution makes at most n queries, you will receive 100 points.\nIf it makes more than n+1000 queries, you will receive 0 points.\nIf it makes x queries where n < x ≤ n+1000, your score will be linearly interpolated\nfrom 100 down to 0.\n\nInput\nThe first line of the input contains a single integer t (1 ≤ t ≤ 100), the number of test cases.\n\nThe first line of each test case contains a single integer n (2 ≤ n ≤ 1000), the size of the tree.\n\nEach of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v),\ndenoting an edge between nodes u and v in the tree.\n\nIt is guaranteed that the sum of n over all test cases does not exceed 1000 and that each graph\nprovided is a valid tree.\n\nInteraction\nAfter printing a query do not forget to output the end of line and flush the output. Otherwise, you\nmay get the Idleness Limit Exceeded verdict.\n\nWhen you have found the answer, output:\n! v1 v2 ... vn\nwhere vi is the value of node i after performing the queries.\n\nPrinting the answer does not count as a query.\n\nExample\n\ninput\n3\n4\n1 4\n4 2\n2 3\n1\n-1\n-5\n-5\n2\n1 2\n2\n7\n1 2\n2 7\n7 3\n7 4\n7 5\n7 6\n-1\n\noutput\n? 1 3 1 2 4\n? 1 2 3 1\n? 2 4\n? 1 3 1 2 4\n? 1 2 3 1\n! -1 -1 -1 -1\n? 1 1 1\n! -1 1 1 1 1 1 -1", "config": "# Set the problem type to interactive\ntype: interactive\n\n# Specify the interactor source file\ninteractor: interactor.cpp\n\n# Time and memory limits still apply to the contestant's solution\ntime: 5s\nmemory: 1024m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 3 # Looks for 1.in, 2.in, ... 5.in"}
|
| 115 |
{"problem_id": "58", "category": "algorithmic", "statement": "Inverse Counting Path\n\nWalk Alone is an expert in dynamic programming, but he gets bored with traditional dynamic programming problem like counting paths on a 2-dimension grid, so he wants to do it in reverse. The problem he raised is as follows:\n\nOn a 2-dimension grid of size n*n, originally you are on grid (1,1). The grid consists of 0 and 1, and you can only walk on the grid with number 1 in it. You can only go down or right, i.e. you can only increase your x or y by one. Also you cannot walk outside the grid.\n\nGiven the number x of ways to walk from (1,1) to (n,n), you need to construct a grid of n*n so that the ways to walk is exactly x. However, since Walk Alone's brain is too small to memorize such a big grid, you need to guarantee that the size of the grid n is equal to or smaller than 300. Specifically, your score will be (300 - n) / 300.\n\nInput\n\nThe only line of the input contains one integer x (1<=x<=10^18), denoting the ways to walk.\n\nOutput\n\nThe first line of the output contains the size of the grid n. Remind that you need to guarantee 1<=n<=300.\n\nThe following n lines each contains n integers a_{i,j}∈{0,1} denoting the grid, where 0 denotes you cannot walk on the grid while 1 is on the contrast.\n\nExample Input 1:\n\n3\n\nExample Output 1:\n\n3\n1 1 0\n1 1 0\n1 1 1\n\nExample Input 2:\n\n10\n\nExample Output 2:\n\n4\n1 1 1 0\n1 1 1 1\n1 0 1 1\n1 1 1 1", "config": "# Set the problem type to interactive\ntype: default\n\n# Specify the interactor source file\ninteractor: chk.cc\n\n# Time and memory limits still apply to the contestant's solution\ntime: 1s\nmemory: 512m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 3 # Looks for 1.in, 2.in, ... 5.in"}
|
| 116 |
{"problem_id": "59", "category": "algorithmic", "statement": "# Limited Shuffle Restoring\n\n**Input file:** standard input \n**Output file:** standard output \n**Time limit:** 3 seconds \n**Memory limit:** 512 meblbytes \n\n**This is an interactive problem.**\n\nBobo had an array \\\\( a \\\\), initially equal to \\\\((1,2,\\ldots,n)\\\\). He did the following operations with the array.\n\n- For each \\\\( i \\\\) from 1 to \\\\( n \\\\) in this order, Bobo picked some index \\\\( j \\\\) such that \\\\( i \\leq j \\leq \\min(n,i+2) \\\\), and swapped \\\\( a_i \\\\) and \\\\( a_j \\\\). Of course, if \\\\( i = j \\\\), then nothing happened after the operation.\n\nYour goal is to determine the final array. You may ask questions of the following type.\n\n- ? i j meaning the question \"How do \\\\( a_i \\\\) and \\\\( a_j \\\\) compare to each other?\". Bobo will respond to this with one symbol < or >, meaning that \\\\( a_i < a_j \\\\) or \\\\( a_i > a_j \\\\), respectively.\n\nYou may ask no more than \\\\(\\lfloor 5n/3 \\rfloor + 5\\\\) questions. After this, you must guess the array.\n\n## Interaction Protocol\n\nFirst, the interactor prints the number \\\\( n \\\\) in a separate line (\\\\( 1 \\leq n \\leq 30,000 \\\\)). Then the solution makes queries, where each query consists of printing ? i j on a separate line, where \\\\( 1 \\leq i,j \\leq n \\\\), and \\\\( i \\neq j \\\\). After each query the interactor prints one character < or > on a separate line.\n\nAfter the solution has finished asking questions, it must make a guess. If you think that the array is \\\\((a_1,\\ldots,a_n)\\\\), print ! \\\\( a_1 \\ a_2 \\ldots \\ a_n \\\\) on a separate line and terminate.\n\nIf your solution makes more than \\\\(\\lfloor 5n/3 \\rfloor + 5\\\\) queries, the interactor will finish with the WA verdict. If you do not flush the output after printing a query, you may receive the IL verdict.\n\nNote that the interactor in this task is **adaptive**, i.e. the array may be generated at the runtime consistently with your questions.\n\n## Example\n\n| standard input | standard output |\n|----------------|-----------------|\n| 5 | ? 5 4 |\n| < | ? 5 1 |\n| > | ? 5 3 |\n| > | ? 3 1 |\n| < | ? 2 1 |\n| > | ? 5 2 |\n| > | ! 2 3 1 5 4 |", "config": "type: interactive\n\ntime: 3s\nmemory: 512m\n\ninteractor: interactor.cpp\ninteractor_type: testlib\n\nsubtasks:\n - score: 100\n n_cases: 3"}
|