Update dataset
Browse files
data/test-00000-of-00001.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{"problem_id": "0", "category": "algorithmic", "statement": "# Pack the Polyominoes (Reflections Allowed)\n\n## Problem\nYou are given a set of n polyominoes placed on a unit square grid. Each polyomino consists of between 1 and 10 unit cells, connected edge-to-edge (4-connectivity). Your task is to place all polyominoes—allowing **rotations, reflections, and translations**—into an axis-aligned rectangle of the grid with no overlaps and no cells outside the rectangle, minimizing the rectangle’s area.\n\nA placement specifies, for every polyomino, an integer translation, an optional reflection, and a rotation by a multiple of 90°, such that:\n\n- every cell lands on integer grid coordinates,\n- no two placed cells overlap,\n- all placed cells lie within a single axis-aligned rectangle of width W and height H.\n\nThe objective is to minimize A = W × H. In case of ties on area, prefer smaller H, then smaller W.\n\n---\n\n## Input Format\n- Line 1: integer n (100 <= n <= 10^4) — number of polyominoes.\n- For each polyomino i = 1 … n:\n - One line: integer kᵢ (1 ≤ kᵢ ≤ 10) — number of cells.\n - Next kᵢ lines: two integers xᵢⱼ, yᵢⱼ — cell coordinates in the polyomino’s local frame.\n These coordinates define a 4-connected polyomino.\n\nNotes:\n- Coordinates may be negative.\n- Shapes may have internal holes.\n- Shapes are defined by structure; initial placement does not matter.\n\n---\n\n## Output Format\n- Line 1: two integers W and H — width and height of the chosen rectangle.\n- Then n lines — one per polyomino i, each containing:\n$$X_i\\ Y_i\\ R_i\\ F_i$$\n\nWhere:\n- (Xᵢ, Yᵢ): integer translation\n- Rᵢ ∈ {0,1,2,3}: number of 90° clockwise rotations\n- Fᵢ ∈ {0,1}: reflection flag (**1 = reflect across the y-axis before rotation**, 0 = no reflection)\n\nAll transformed cells must satisfy:\n0 ≤ xᵢⱼ′ < W, 0 ≤ yᵢⱼ′ < H\n\n---\n\n## Rules\n1. All cells occupy unit squares with integer coordinates.\n2. **Allowed transforms: reflection (optional) → rotation (0°, 90°, 180°, 270°) → translation (in that order).**\n3. Distinct polyomino cells must not overlap.\n4. Every cell must lie inside [0, W) × [0, H).\n5. Scoring: Minimize A = W × H.\n\n---\n\n## Constraints\n- 100 ≤ n ≤ 10000\n- 1 ≤ kᵢ ≤ 10\n\n---\n\n## Validation\nA solution is valid if:\n- All rules are satisfied.\n- The judge verifies non-overlap and bounding-box compliance.\n\n---\n\n## Scoring\n\nLet x be A=W*H, the rectangle area. C is the total number of occupied cells in the pieces. The physical reference (the 60-point level) is a=C/0.6. Define the lower-band continuation:\n\n L(x) = 100*C/x.\n\nFor positive x and positive physical reference a, define the improvement factor r=a/x. The physical reference has r=1 and earns 60 points. For a valid output on this branch, the points P are:\n\n P = 100, if x=0;\n P = L(x), if L(x)<=60;\n P = min(100,60+ln(r)), otherwise.\n\nHere ln is the natural logarithm. In the upper branch before the 100-point cap, r=exp(P-60): each additional point requires an e-fold improvement in the physical objective (division by e). All feasibility, correctness, and hard resource-limit checks remain required; invalid output receives 0.\n\nAcross test files, use the arithmetic mean of the file scores.\n\n\n## Example\n\nThis small example illustrates placement and scoring. Official inputs have n >= 100.\n\nInput\n```\n3\n1\n0 0\n3\n0 0\n1 0\n0 1\n4\n0 0\n1 0\n0 1\n1 1\n```\n\nOutput\n```\n3 3\n2 0 0 0\n2 2 2 0\n0 0 0 0\n```\n\nThis places the monomino at (2,0), rotates the triomino by 180° (R=2), and fits all shapes into a 3×3 rectangle without reflections. The pieces occupy C=8 cells and A=9, giving 60+ln((8/0.6)/9), approximately 60.393 points.\n\n---\n\n## Generation\n\nLet $S$ be the set of all pieces from size 1-10. Each piece is chosen uniformly at random with replacement from $S$.\n\n$n$ is chosen as $10^p$, where $p \\sim U(2, 4)$.\n", "config": "\ntype: default\nchecker: chk.cc\n\n# Time and memory limits still apply to the contestant's solution\ntime: 2s\nmemory: 256m\n\n# The subtasks section works the same way\nsubtasks:\n- score: 100\n n_cases: 70"}
|
| 2 |
{"problem_id": "1", "category": "algorithmic", "statement": "Problem F: Treasure Packing\n\nA dragon has terrorized the region for decades, breathing fire and stealing treasures. A hero has decided to steal back the treasures and return them to the community. However, they drastically underestimated the size of the dragon's hoard, bringing only a single 25 liter bag, only strong enough to hold 20 kg, to carry out the treasures. The hero has decided to try to return as much value as possible. The dragon has 12 different types of items of different values, masses, and volumes: crowns, figurines, jeweled goblets, gold helms, etc., where each item of the same type has the same mass and volume. For example, all goblets have the same mass and volume. Write a program helping the hero determine what items they should put in the bag so as to maximize value accounting for the constraints on the bag.\n\nInput\nThe input is JSON keyed by treasure category name, such as \"goblet\". Every category has a unique name composed of at most 100 lowercase ASCII characters. There are exactly twelve treasure categories. Each corresponding value is a list with one integer q (1 <= q <= 10000) and three integers v (0 < v <= 10^9), m (0 < m <= 20 * 10^6), and l (0 < l <= 25 * 10^6), where q is the maximum number of treasures of this category that can be looted, v is the value of one item, m is the mass (in mg) of one item, and l the volume (in µliters) of one item. (There are one million mg per kg and µliters per liter.)\n\nPlease see the sample input for an example of how the JSON is formatted.\n\nOutput\nPrint a JSON with the same keys as the input, but with single a nonnegative integer values giving the numbers of items of that category added to the bag in your solution.\n\n## Scoring\n\nLet x be V, the total packed value. B is the stored heuristic baseline value and R>B is the stored comparison value. The physical reference (the 60-point level) is a=R. Define the lower-band continuation:\n\n L(x) = 60*max(0,(x-B)/(R-B)).\n\nFor positive x and positive physical reference a, define the improvement factor r=x/a. The physical reference has r=1 and earns 60 points. For a valid output on this branch, the points P are:\n\n P = L(x), if L(x)<=60;\n P = min(100,60+ln(r)), otherwise.\n\nHere ln is the natural logarithm. In the upper branch before the 100-point cap, r=exp(P-60): each additional point requires an e-fold improvement in the physical objective (multiplication by e). A zero maximization objective is not a full-score exception. All feasibility, correctness, and hard resource-limit checks remain required; invalid output receives 0.\n\nAcross test files, use the arithmetic mean of the file scores.\n\n\nSample input:\n{\n \"circlet\": [\n 19,\n 113005,\n 146800,\n 514247\n ],\n \"coppercoin\": [\n 887,\n 6171,\n 12593,\n 18081\n ],\n \"crown\": [\n 13,\n 726439,\n 1079353,\n 1212213\n ],\n \"dagger\": [\n 21,\n 279513,\n 558367,\n 522344\n ],\n \"figurine\": [\n 18,\n 26272,\n 1488281,\n 2295986\n ],\n \"goblet\": [\n 22,\n 300053,\n 698590,\n 986387\n ],\n \"goldcoin\": [\n 129,\n 14426,\n 82176,\n 27597\n ],\n \"helm\": [\n 3,\n 974983,\n 2470209,\n 882803\n ],\n \"jewelry\": [\n 23,\n 272450,\n 171396,\n 262226\n ],\n \"plate\": [\n 22,\n 98881,\n 246257,\n 363420\n ],\n \"silvercoin\": [\n 288,\n 12587,\n 53480,\n 28654\n ],\n \"torc\": [\n 17,\n 244957,\n 388222,\n 500000\n ]\n}\n\nSample Output:\n{\n \"circlet\": 2,\n \"coppercoin\": 8,\n \"crown\": 13,\n \"dagger\": 0,\n \"figurine\": 0,\n \"goblet\": 0,\n \"goldcoin\": 0,\n \"helm\": 0,\n \"jewelry\": 23,\n \"plate\": 0,\n \"silvercoin\": 1,\n \"torc\": 4\n}\n", "config": "type: default\n# The time limit is now 1 second.\ntime: 1s\nmemory: 1024m\n# A custom checker is required for the special scoring.\nchecker: chk.cc\nsubtasks:\n - score: 100\n n_cases: 20"}
|
| 3 |
{"problem_id": "10", "category": "algorithmic", "statement": "Problem: Tree distance\n\nTime limit: 2 second\n\nMemory limit: 512 MB\n\nThis is an interactive problem.\n\nLittle Cyan Fish has a weighted tree of n verticies generated in the following way:\n- First, generate a random labeled tree: uniformly randomly select from all nn−2 possible labeled trees.\n- Then, independently assign random integer edge weights in the range [1, K] to each edge, where K is a hidden parameter.\n\nYou cannot directly observe the structure of the tree or the edge weights, but Little Cyan Fish grants\nyou a superpower: querying! Each time, you can query the distance between two vertices. Specifically, you\ncan choose two vertices u, v (1 \\leq u, v \\leq n, u \\neq v), and we will tell you the distance between these two\nvertices (i.e., the sum of the edge weights on the simple path connecting these two vertices).\n\nNow, Little Cyan Fish wants you to determine all the edges and their weights within queries as less as you can.\n\n## Scoring\n\nLet x be Q, the query count in a group. Z=floor(n*n/3). The physical reference (the 60-point level) is a=5*n. Define the lower-band continuation:\n\n L(x) = 60*max(0,(Z-x)/(Z-5*n)) if n>=16; 60*(5*n+1)/(x+1) if n<=15.\n\nFor positive x and positive physical reference a, define the improvement factor r=a/x. The physical reference has r=1 and earns 60 points. For a valid output on this branch, the points P are:\n\n P = 100, if x=0;\n P = L(x), if L(x)<=60;\n P = min(100,60+ln(r)), otherwise.\n\nHere ln is the natural logarithm. In the upper branch before the 100-point cap, r=exp(P-60): each additional point requires an e-fold improvement in the physical objective (division by e). All feasibility, correctness, and hard resource-limit checks remain required; invalid output receives 0.\n\nScore each subcase separately and take their arithmetic mean.\n\nAcross test files, use the arithmetic mean of the file scores.\n\n\nInteraction Protocol\n\nEach test case contains multiple sets of test data. First, you need to read an integer T (1 \\leq T \\leq 10^4)\nindicating the number of data sets.\nFor each set of test data, you first need to read an integer n (1 \\leq n \\leq 10^5).\nNext, the interaction process begins. To\nmake a query, you need to output a line “? u v” (1 \\leq u, v \\leq n, u \\neq v), describing a query. Then, you need\nto read the result from standard input.\nTo provide your answer, you need to output “! u_1 v_1 w_1 u_2 v_2 w_2··· u_{n−1} v_{n−1} w_{n−1}”. You can output\nthese edges in any order. The hard query limit for each group is n*(n+1)/2. The output of the final answer does not count toward this limit. The value floor(n*n/3) is used only in the scoring formula. After you\noutput the answer, you need to immediately read the next set of test data or terminate your program.\nAfter outputting a query, do not forget to output a newline character and flush the output stream.\nTo do this, you can use fflush(stdout) or cout.flush() in C++, System.out.flush() in Java,\nflush(output) in Pascal, or stdout.flush() in Python.\nIt is guaranteed that 1 \\leq K \\leq 10^4, and the sum of all n in the test data does not exceed 10^5.\n\nIn this problem, it is guaranteed that the interaction library is non-adaptive. That is, the shape of the\ntree and the edge weights are determined before the interaction process. They will not change with your\nqueries.\n\nExample input:\n2\n3\n\n3\n\n4\n\n7\n\n4\n\n3\n\n7\n\n2\n\n4\n\n5\n\n9\n\nExample Output:\n\n\n? 1 2\n\n? 2 3\n\n? 1 3\n\n! 1 2 3 2 3 4\n\n? 1 2\n\n? 2 3\n\n? 2 4\n\n? 1 3\n\n? 1 4\n\n? 3 4\n\n! 1 2 3 1 3 4 2 4 2\n", "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: 10 # Looks for 1.in, 2.in, ... 5.in"}
|
| 4 |
-
{"problem_id": "101", "category": "algorithmic", "statement": "Problem Name: Circuit\n\nDescription:\nYou are given a circuit board consisting of N component slots
|
| 5 |
{"problem_id": "104", "category": "algorithmic", "statement": "Time Limit: 2 s\nMemory Limit: 256 MB\nThis is an interactive problem.\nThere are n students, having roll numbers 1 to n. Mr. 1048576 knows that exactly 1 student is absent today. In order to determine who is absent, he can ask some queries to the class. In each query, he provide two integers l and r (1≤l≤r≤n) and all students whose roll numbers are between l and r (inclusive) are expected to raise their hands.\nBut the students are dishonest. Some students whose roll numbers lie in the given range may not raise their hands, while some other students whose roll number does not lie in the given range may raise their hands. But only the following 4 cases are possible for a particular query (l,r) —\n1. True Positive: r−l+1 students are present and r−l+1 students raised their hands.\n2. True Negative: r−l students are present and r−l students raised their hands.\n3. False Positive: r−l students are present but r−l+1 students raised their hands.\n4. False Negative: r−l+1 students are present but r−l students raised their hands.\nIn the first two cases, the students are said to be answering honestly, while in the last two cases, the students are said to be answering dishonestly. The students can mutually decide upon their strategy, not known to Mr. 1048576. Also, their strategy always meets the following two conditions —\n1. The students will never answer honestly 3 times in a row.\n2. The students will never answer dishonestly 3 times in a row.\nMr. 1048576 is willing to mark at most 2 students as absent (though he knows that only one is). The attendance is said to be successful if the student who is actually absent is among those two. Also, he can only ask up to 2* ⌈log_{1.116}n⌉ queries. Help him complete a successful attendance.\n\nInteraction\nFirst read a line containing a single integer t (1≤t≤2048) denoting the number of independent test cases that you must solve.\nFor each test case, first read a line containing a single integer n (5≤n≤10^5). Then you may ask up to 2* ⌈log_{1.116}n⌉ queries.\nYour score depends on the query count as specified below.\nTo ask a query, print a single line in the format \"? l r\" (without quotes) (1≤l≤r≤n). Then read a single line containing a single integer x (r−l≤x≤r−l+1) denoting the number of students who raised their hands corresponding to the query.\nTo mark a student as absent, print a single line in the format \"! a\" (without quotes) (1≤a≤n). Then read a single integer y (y∈{0,1}). If the student with roll number a was absent, y=1, else, y=0. Note that this operation does not count as a query but you can do this operation at most 2 times.\nTo end a test case, print a single line in the format \"#\" (without quotes). Then you must continue solving the remaining test cases.\nThe sum of n over all test cases does not exceed 10^5.\nTo flush the buffer, use fflush(stdout) or cout.flush()\nThe answer may change depending on your queries but will always remain consistent with the constraints and the answer to the previous queries.\nExample\ninput\n2\n5\n3\n2\n1\n2\n0\n1\n0\n2\n0\n1\n6\n6\n2\n2\n0\n1\n1\n0\n0\n0\n1\noutput\n? 1 4\n? 3 5\n? 2 2\n? 1 3\n? 3 3\n? 3 3\n! 3\n? 2 4\n? 4 4\n! 2\n#\n? 1 6\n? 1 3\n? 4 6\n? 1 1\n? 3 3\n? 5 5\n! 3\n? 2 2\n? 4 4\n! 4\n#\n\n## Scoring\n\nAll feasibility and interaction limits apply before scoring; invalid output receives zero. Points are averaged over test files. For the logarithmic branch, write x for the original minimizing quantity and a for its physical 60-point reference. The improvement factor is r=a/x, and the upper-band award is P=min(100,60+ln(r)). Here ln is natural: r=1 corresponds to 60 points, and on the uncapped logarithmic upper band, r=exp(P-60). Each additional point multiplies the physical improvement factor by e (divides a minimizing objective by e or multiplies a maximizing objective by e, as applicable). The lower-band, zero-objective, and completion rules below still apply.\n\nFor subcase j, let Q_j be its query count and L_j>1 its query limit. Define the per-subcase physical reference a_j=A_j=0.4*L_j+0.6 and B_j=100*min(1,max(0,(L_j-Q_j)/(L_j-1))). Guess actions are not queries.\n\nFor a valid subcase, award 100 if Q_j=0; otherwise award B_j when B_j<=60, and min(100,60+ln(r_j)) when B_j>60, where x_j=Q_j and r_j=a_j/x_j. The file score is the minimum subcase award. A failed subcase gives zero for the file. The checker reports the file score divided by 100.\n", "config": "type: interactive\ntime: 2s\nmemory: 256m\n# A custom checker is required for the special scoring.\nchecker: interactor.cc\nsubtasks:\n - score: 100\n n_cases: 10"}
|
| 6 |
{"problem_id": "106", "category": "algorithmic", "statement": "Hidden Bipartite Graph\n\nThis is an I/O interactive problem. I/O interaction refers to interactive problems, where the program communicates with a special judge during execution instead of producing all output at once. In these problems, the program sends queries (output) to the judge and must immediately read responses (input) before continuing. The solution must strictly follow the input-output protocol defined in the problem statement, because any extra output, missing flush, or incorrect format can cause a wrong answer. Unlike standard problems, interactive problems require careful handling of I/O, synchronization, and flushing to ensure smooth communication between the contestant’s code and the judge.\n\nBob has a simple undirected connected graph (without self-loops and multiple edges). He wants to learn whether his graph is bipartite (that is, you can paint all vertices of the graph into two colors so that there is no edge connecting two vertices of the same color) or not. As he is not very good at programming, he asked Alice for help. He does not want to disclose his graph to Alice, but he agreed that Alice can ask him some questions about the graph.\nThe only question that Alice can ask is the following: she sends s — a subset of vertices of the original graph. Bob answers with the number of edges that have both endpoints in s. Since he doesn't want Alice to learn too much about the graph, he allows her to ask no more than 5000 questions.\nFurthermore, he suspects that Alice might introduce false messages to their communication channel, so when Alice finally tells him whether the graph is bipartite or not, she also needs to provide a proof — either the partitions themselves or a cycle of odd length.\nYour task is to help Alice to construct the queries, find whether the graph is bipartite. Points depend on the number of queries as defined in Scoring.\n\nInput\n\nThe first line contains a single integer n (1 ≤ n ≤ 600) — the number of vertices in Bob's graph.\n\nInteraction\n\nFirst, read an integer n (1≤ n ≤ 600) — the number of vertices in Bob's graph.\nTo make a query, print two lines. First of which should be in the format \"? k\" (1 ≤ k ≤ n), where k is the size of the set to be queried. The second line should contain k space separated distinct integers s1, s2, ..., sk (1 ≤ si ≤ n) — the vertices of the queried set.\n\nAfter each query read a single integer m (0 ≤ m ≤ n(n-1)/2) — the number of edges between the vertices of the set {si}.\nYou are not allowed to ask more than 5000 queries.\n\nIf m = -1, it means that you asked more queries than allowed, or asked an invalid query. Your program should immediately terminate (for example, by calling exit(0)). You will receive Wrong Answer; it means that you asked more queries than allowed, or asked an invalid query. If you ignore this, you can get other verdicts since your program will continue to read from a closed stream.\nAfter printing a query do not forget to print end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:\n\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\nWhen you know the answer, you need to print it.\n\nThe format of the answer depends on whether the graph is bipartite or not.\nIf the graph is bipartite, print two lines. The first should contain the letter \"Y\" (short for \"YES\") followed by a space, and then a single integer s (0 ≤ s ≤ n) — the number of vertices in one of the partitions. Second line should contain s integers a1, a2, ..., as — vertices belonging to the first partition. All ai must be distinct, and all edges in the main graph must have exactly one endpoint in the set {ai}.\nIf the graph is not bipartite, print two lines. The first should contain the letter \"N\" (short for \"NO\") followed by a space, and then a single integer l (3 ≤ l ≤ n) — the length of one simple cycle of odd length. Second line should contain l integers c1, c2, ..., cl — the vertices along the cycle. It must hold that for all 1 ≤ i ≤ l, there is an edge {ci, c_{(i mod l)+1}} in the main graph, and all ci are distinct.\nIf there are multiple possible answers, you may print any of them.\n\nExamples\n\nInput\n\n 4\n 4\n 0\n 1\n 1\n 1\n 0\n\nOutput\n ? 4\n 1 2 3 4\n ? 2\n 1 2\n ? 2\n 1 3\n ? 2\n 1 4\n ? 2\n 2 4\n ? 2\n 3 4\n Y 2\n 1 2\n\nInput\n\n 4\n 4\n 3\n\nOutput\n\n ? 4\n 1 4 2 3\n ? 3\n 1 2 4\n N 3\n 2 1 4\n\nNote\nIn the first case, Alice learns that there are 4 edges in the whole graph. Over the course of the next three queries, she learns that vertex 1 has two neighbors: 3 and 4. She then learns that while vertex 2 is adjacent to 4, the vertex 3 isn't adjacent to 4. There is only one option for the remaining edge, and that is (2, 3). This means that the graph is a cycle on four vertices, with (1, 2) being one partition and (3, 4) being the second.\nHere, it would be also valid to output \"3 4\" on the second line.\nIn the second case, we also have a graph on four vertices and four edges. In the second query, Alice learns that there are three edges among vertices (1, 2, 4). The only way this could possibly happen is that those form a triangle. As the triangle is not bipartite, Alice can report it as a proof. Notice that she does not learn where the fourth edge is, but she is able to answer Bob correctly anyway.\n\n## Scoring\n\nAll feasibility and interaction limits apply before scoring; invalid output receives zero. Points are averaged over test files. For the logarithmic branch, write x for the original minimizing quantity and a for its physical 60-point reference. The improvement factor is r=a/x, and the upper-band award is P=min(100,60+ln(r)). Here ln is natural: r=1 corresponds to 60 points, and on the uncapped logarithmic upper band, r=exp(P-60). Each additional point multiplies the physical improvement factor by e (divides a minimizing objective by e or multiplies a maximizing objective by e, as applicable). The lower-band, zero-objective, and completion rules below still apply.\n\nQ is the number of subset queries, excluding the final answer; the final answer contributes one round to the lower-band formula. Define the objective x=Q, its physical reference a=A=1999, and the lower-band calculation L=100*max(0,1-(Q+1)/5000).\n\n```text\nP = 100, if x = 0\nP = L, if L <= 60 and x > 0\nP = min(100, 60 + ln(r)), otherwise\n```\n\nZero is tested on the valid original count, cost, or error, before the lower-band test. A zero reference anchor has no positive improvement branch; positive objectives keep their lower-band score. The checker reports P/100.\n", "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: 10s\nmemory: 256m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 100 # Looks for 1.in, 2.in, ... 5.in"}
|
| 7 |
{"problem_id": "107", "category": "algorithmic", "statement": "F. Guess Divisors Count\n\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nThis is an I/O interactive problem. I/O interaction refers to interactive problems, where the program communicates with a special judge during execution instead of producing all output at once. In these problems, the program sends queries (output) to the judge and must immediately read responses (input) before continuing. The solution must strictly follow the input-output protocol defined in the problem statement, because any extra output, missing flush, or incorrect format can cause a wrong answer. Unlike standard problems, interactive problems require careful handling of I/O, synchronization, and flushing to ensure smooth communication between the contestant’s code and the judge.\n\nWe have hidden an integer 1 ≤ X ≤ 10^9. You don't have to guess this number. You have to find the number of divisors of this number, and you don't even have to find the exact number: your answer will be considered correct if its absolute error is not greater than 7 or its relative error is not greater than 0.5.\nMore formally, let your answer be ans and the number of divisors of X be d, then your answer will be considered correct if at least one of the two following conditions is true:\n * | ans - d | ≤ 7;\n * 1/2 ≤ ans / d ≤ 2.\n\nYou can make at most 100 queries. One query consists of one integer 1 ≤ Q ≤ 10^18. In response, you will get gcd(X, Q) — the greatest common divisor of X and Q.\n\nThe number X is fixed before all queries. In other words, interactor is not adaptive.\nLet's call the process of guessing the number of divisors of number X a game. In one test you will have to play T independent games, that is, guess the number of divisors T times for T independent values of X. The score uses the maximum query count across games, as defined in Scoring.\n\nInput\n\nThe first line of input contains one integer T (1 ≤ T ≤ 100) — the number of games.\n\nInteraction\n\nTo make a query print a line \"0 Q\" (1 ≤ Q ≤ 10^18). After that read one integer gcd(X, Q). You can make no more than 100 such queries during one game.\nIf you are confident that you have figured out the number of divisors of X with enough precision, you can print your answer in \"1 ans\" format. ans have to be an integer. If this was the last game, you have to terminate the program, otherwise you have to start the next game immediately. Note that the interactor doesn't print anything in response to you printing answer.\n\nAfter printing a query do not forget to output end of line and flush the output. 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\nExample\nInput (from interactor to you)\n\n 2\n\n 1\n\n 1\n\n 1\n\n 1024\n\n 1048576\n\n 4194304\n\nOutput (from you to interactor)\n\n 0 982306799268821872\n\n 0 230856864650023977\n\n 0 134690134760714371\n\n 1 5\n 0 1024\n\n 0 1048576\n\n 0 1073741824\n\n 1 42\n\nNote\n\nLet's look at the example.\nIn the first game X = 998244353 is hidden. Would be hard to guess this, right? This number is prime, so the number of its divisors is 2. The solution has made several random queries, and all the responses turned out to be 1 (strange things, not even one of three random numbers is divisible by 998244353). It's fare to assume that the hidden number doesn't have many divisors, so the solution has answered 5. Why not. This answer will be considered correct since | 5 - 2 | = 3 ≤ 7.\nIn the second game X = 4,194,304 = 2^22 is hidden, it has 23 divisors. The solution has made queries 1024 = 2^10, 1,048,576 =2^20, 1,073,741,824 = 2^30 and got responses 1024 = 2^10, 1,048,576 =2^20, 4,194,304 = 2^22, respectively. Then the solution got completely confused and answered the answer to The Ultimate Question of Life, the Universe, and Everything.\nThis answer will be considered correct since 1/2 ≤ 42 / 23 ≤ 2.\n\n## Scoring\n\nAll feasibility and interaction limits apply before scoring; invalid output receives zero. Points are averaged over test files. For the logarithmic branch, write x for the original minimizing quantity and a for its physical 60-point reference. The improvement factor is r=a/x, and the upper-band award is P=min(100,60+ln(r)). Here ln is natural: r=1 corresponds to 60 points, and on the uncapped logarithmic upper band, r=exp(P-60). Each additional point multiplies the physical improvement factor by e (divides a minimizing objective by e or multiplies a maximizing objective by e, as applicable). The lower-band, zero-objective, and completion rules below still apply.\n\nQ is the maximum query count across the games in this file; every answer must satisfy the allowed error. Define the objective x=Q, its physical reference a=A=40, and the lower-band calculation L=100*(1-Q/100).\n\n```text\nP = 100, if x = 0\nP = L, if L <= 60 and x > 0\nP = min(100, 60 + ln(r)), otherwise\n```\n\nZero is tested on the valid original count, cost, or error, before the lower-band test. A zero reference anchor has no positive improvement branch; positive objectives keep their lower-band score. Use the maximum count across games, not an average. The checker reports P/100.\n", "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: 2s\nmemory: 256m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 10 # Looks for 1.in, 2.in, ... 5.in"}
|
|
|
|
| 1 |
{"problem_id": "0", "category": "algorithmic", "statement": "# Pack the Polyominoes (Reflections Allowed)\n\n## Problem\nYou are given a set of n polyominoes placed on a unit square grid. Each polyomino consists of between 1 and 10 unit cells, connected edge-to-edge (4-connectivity). Your task is to place all polyominoes—allowing **rotations, reflections, and translations**—into an axis-aligned rectangle of the grid with no overlaps and no cells outside the rectangle, minimizing the rectangle’s area.\n\nA placement specifies, for every polyomino, an integer translation, an optional reflection, and a rotation by a multiple of 90°, such that:\n\n- every cell lands on integer grid coordinates,\n- no two placed cells overlap,\n- all placed cells lie within a single axis-aligned rectangle of width W and height H.\n\nThe objective is to minimize A = W × H. In case of ties on area, prefer smaller H, then smaller W.\n\n---\n\n## Input Format\n- Line 1: integer n (100 <= n <= 10^4) — number of polyominoes.\n- For each polyomino i = 1 … n:\n - One line: integer kᵢ (1 ≤ kᵢ ≤ 10) — number of cells.\n - Next kᵢ lines: two integers xᵢⱼ, yᵢⱼ — cell coordinates in the polyomino’s local frame.\n These coordinates define a 4-connected polyomino.\n\nNotes:\n- Coordinates may be negative.\n- Shapes may have internal holes.\n- Shapes are defined by structure; initial placement does not matter.\n\n---\n\n## Output Format\n- Line 1: two integers W and H — width and height of the chosen rectangle.\n- Then n lines — one per polyomino i, each containing:\n$$X_i\\ Y_i\\ R_i\\ F_i$$\n\nWhere:\n- (Xᵢ, Yᵢ): integer translation\n- Rᵢ ∈ {0,1,2,3}: number of 90° clockwise rotations\n- Fᵢ ∈ {0,1}: reflection flag (**1 = reflect across the y-axis before rotation**, 0 = no reflection)\n\nAll transformed cells must satisfy:\n0 ≤ xᵢⱼ′ < W, 0 ≤ yᵢⱼ′ < H\n\n---\n\n## Rules\n1. All cells occupy unit squares with integer coordinates.\n2. **Allowed transforms: reflection (optional) → rotation (0°, 90°, 180°, 270°) → translation (in that order).**\n3. Distinct polyomino cells must not overlap.\n4. Every cell must lie inside [0, W) × [0, H).\n5. Scoring: Minimize A = W × H.\n\n---\n\n## Constraints\n- 100 ≤ n ≤ 10000\n- 1 ≤ kᵢ ≤ 10\n\n---\n\n## Validation\nA solution is valid if:\n- All rules are satisfied.\n- The judge verifies non-overlap and bounding-box compliance.\n\n---\n\n## Scoring\n\nLet x be A=W*H, the rectangle area. C is the total number of occupied cells in the pieces. The physical reference (the 60-point level) is a=C/0.6. Define the lower-band continuation:\n\n L(x) = 100*C/x.\n\nFor positive x and positive physical reference a, define the improvement factor r=a/x. The physical reference has r=1 and earns 60 points. For a valid output on this branch, the points P are:\n\n P = 100, if x=0;\n P = L(x), if L(x)<=60;\n P = min(100,60+ln(r)), otherwise.\n\nHere ln is the natural logarithm. In the upper branch before the 100-point cap, r=exp(P-60): each additional point requires an e-fold improvement in the physical objective (division by e). All feasibility, correctness, and hard resource-limit checks remain required; invalid output receives 0.\n\nAcross test files, use the arithmetic mean of the file scores.\n\n\n## Example\n\nThis small example illustrates placement and scoring. Official inputs have n >= 100.\n\nInput\n```\n3\n1\n0 0\n3\n0 0\n1 0\n0 1\n4\n0 0\n1 0\n0 1\n1 1\n```\n\nOutput\n```\n3 3\n2 0 0 0\n2 2 2 0\n0 0 0 0\n```\n\nThis places the monomino at (2,0), rotates the triomino by 180° (R=2), and fits all shapes into a 3×3 rectangle without reflections. The pieces occupy C=8 cells and A=9, giving 60+ln((8/0.6)/9), approximately 60.393 points.\n\n---\n\n## Generation\n\nLet $S$ be the set of all pieces from size 1-10. Each piece is chosen uniformly at random with replacement from $S$.\n\n$n$ is chosen as $10^p$, where $p \\sim U(2, 4)$.\n", "config": "\ntype: default\nchecker: chk.cc\n\n# Time and memory limits still apply to the contestant's solution\ntime: 2s\nmemory: 256m\n\n# The subtasks section works the same way\nsubtasks:\n- score: 100\n n_cases: 70"}
|
| 2 |
{"problem_id": "1", "category": "algorithmic", "statement": "Problem F: Treasure Packing\n\nA dragon has terrorized the region for decades, breathing fire and stealing treasures. A hero has decided to steal back the treasures and return them to the community. However, they drastically underestimated the size of the dragon's hoard, bringing only a single 25 liter bag, only strong enough to hold 20 kg, to carry out the treasures. The hero has decided to try to return as much value as possible. The dragon has 12 different types of items of different values, masses, and volumes: crowns, figurines, jeweled goblets, gold helms, etc., where each item of the same type has the same mass and volume. For example, all goblets have the same mass and volume. Write a program helping the hero determine what items they should put in the bag so as to maximize value accounting for the constraints on the bag.\n\nInput\nThe input is JSON keyed by treasure category name, such as \"goblet\". Every category has a unique name composed of at most 100 lowercase ASCII characters. There are exactly twelve treasure categories. Each corresponding value is a list with one integer q (1 <= q <= 10000) and three integers v (0 < v <= 10^9), m (0 < m <= 20 * 10^6), and l (0 < l <= 25 * 10^6), where q is the maximum number of treasures of this category that can be looted, v is the value of one item, m is the mass (in mg) of one item, and l the volume (in µliters) of one item. (There are one million mg per kg and µliters per liter.)\n\nPlease see the sample input for an example of how the JSON is formatted.\n\nOutput\nPrint a JSON with the same keys as the input, but with single a nonnegative integer values giving the numbers of items of that category added to the bag in your solution.\n\n## Scoring\n\nLet x be V, the total packed value. B is the stored heuristic baseline value and R>B is the stored comparison value. The physical reference (the 60-point level) is a=R. Define the lower-band continuation:\n\n L(x) = 60*max(0,(x-B)/(R-B)).\n\nFor positive x and positive physical reference a, define the improvement factor r=x/a. The physical reference has r=1 and earns 60 points. For a valid output on this branch, the points P are:\n\n P = L(x), if L(x)<=60;\n P = min(100,60+ln(r)), otherwise.\n\nHere ln is the natural logarithm. In the upper branch before the 100-point cap, r=exp(P-60): each additional point requires an e-fold improvement in the physical objective (multiplication by e). A zero maximization objective is not a full-score exception. All feasibility, correctness, and hard resource-limit checks remain required; invalid output receives 0.\n\nAcross test files, use the arithmetic mean of the file scores.\n\n\nSample input:\n{\n \"circlet\": [\n 19,\n 113005,\n 146800,\n 514247\n ],\n \"coppercoin\": [\n 887,\n 6171,\n 12593,\n 18081\n ],\n \"crown\": [\n 13,\n 726439,\n 1079353,\n 1212213\n ],\n \"dagger\": [\n 21,\n 279513,\n 558367,\n 522344\n ],\n \"figurine\": [\n 18,\n 26272,\n 1488281,\n 2295986\n ],\n \"goblet\": [\n 22,\n 300053,\n 698590,\n 986387\n ],\n \"goldcoin\": [\n 129,\n 14426,\n 82176,\n 27597\n ],\n \"helm\": [\n 3,\n 974983,\n 2470209,\n 882803\n ],\n \"jewelry\": [\n 23,\n 272450,\n 171396,\n 262226\n ],\n \"plate\": [\n 22,\n 98881,\n 246257,\n 363420\n ],\n \"silvercoin\": [\n 288,\n 12587,\n 53480,\n 28654\n ],\n \"torc\": [\n 17,\n 244957,\n 388222,\n 500000\n ]\n}\n\nSample Output:\n{\n \"circlet\": 2,\n \"coppercoin\": 8,\n \"crown\": 13,\n \"dagger\": 0,\n \"figurine\": 0,\n \"goblet\": 0,\n \"goldcoin\": 0,\n \"helm\": 0,\n \"jewelry\": 23,\n \"plate\": 0,\n \"silvercoin\": 1,\n \"torc\": 4\n}\n", "config": "type: default\n# The time limit is now 1 second.\ntime: 1s\nmemory: 1024m\n# A custom checker is required for the special scoring.\nchecker: chk.cc\nsubtasks:\n - score: 100\n n_cases: 20"}
|
| 3 |
{"problem_id": "10", "category": "algorithmic", "statement": "Problem: Tree distance\n\nTime limit: 2 second\n\nMemory limit: 512 MB\n\nThis is an interactive problem.\n\nLittle Cyan Fish has a weighted tree of n verticies generated in the following way:\n- First, generate a random labeled tree: uniformly randomly select from all nn−2 possible labeled trees.\n- Then, independently assign random integer edge weights in the range [1, K] to each edge, where K is a hidden parameter.\n\nYou cannot directly observe the structure of the tree or the edge weights, but Little Cyan Fish grants\nyou a superpower: querying! Each time, you can query the distance between two vertices. Specifically, you\ncan choose two vertices u, v (1 \\leq u, v \\leq n, u \\neq v), and we will tell you the distance between these two\nvertices (i.e., the sum of the edge weights on the simple path connecting these two vertices).\n\nNow, Little Cyan Fish wants you to determine all the edges and their weights within queries as less as you can.\n\n## Scoring\n\nLet x be Q, the query count in a group. Z=floor(n*n/3). The physical reference (the 60-point level) is a=5*n. Define the lower-band continuation:\n\n L(x) = 60*max(0,(Z-x)/(Z-5*n)) if n>=16; 60*(5*n+1)/(x+1) if n<=15.\n\nFor positive x and positive physical reference a, define the improvement factor r=a/x. The physical reference has r=1 and earns 60 points. For a valid output on this branch, the points P are:\n\n P = 100, if x=0;\n P = L(x), if L(x)<=60;\n P = min(100,60+ln(r)), otherwise.\n\nHere ln is the natural logarithm. In the upper branch before the 100-point cap, r=exp(P-60): each additional point requires an e-fold improvement in the physical objective (division by e). All feasibility, correctness, and hard resource-limit checks remain required; invalid output receives 0.\n\nScore each subcase separately and take their arithmetic mean.\n\nAcross test files, use the arithmetic mean of the file scores.\n\n\nInteraction Protocol\n\nEach test case contains multiple sets of test data. First, you need to read an integer T (1 \\leq T \\leq 10^4)\nindicating the number of data sets.\nFor each set of test data, you first need to read an integer n (1 \\leq n \\leq 10^5).\nNext, the interaction process begins. To\nmake a query, you need to output a line “? u v” (1 \\leq u, v \\leq n, u \\neq v), describing a query. Then, you need\nto read the result from standard input.\nTo provide your answer, you need to output “! u_1 v_1 w_1 u_2 v_2 w_2··· u_{n−1} v_{n−1} w_{n−1}”. You can output\nthese edges in any order. The hard query limit for each group is n*(n+1)/2. The output of the final answer does not count toward this limit. The value floor(n*n/3) is used only in the scoring formula. After you\noutput the answer, you need to immediately read the next set of test data or terminate your program.\nAfter outputting a query, do not forget to output a newline character and flush the output stream.\nTo do this, you can use fflush(stdout) or cout.flush() in C++, System.out.flush() in Java,\nflush(output) in Pascal, or stdout.flush() in Python.\nIt is guaranteed that 1 \\leq K \\leq 10^4, and the sum of all n in the test data does not exceed 10^5.\n\nIn this problem, it is guaranteed that the interaction library is non-adaptive. That is, the shape of the\ntree and the edge weights are determined before the interaction process. They will not change with your\nqueries.\n\nExample input:\n2\n3\n\n3\n\n4\n\n7\n\n4\n\n3\n\n7\n\n2\n\n4\n\n5\n\n9\n\nExample Output:\n\n\n? 1 2\n\n? 2 3\n\n? 1 3\n\n! 1 2 3 2 3 4\n\n? 1 2\n\n? 2 3\n\n? 2 4\n\n? 1 3\n\n? 1 4\n\n? 3 4\n\n! 1 2 3 1 3 4 2 4 2\n", "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: 10 # Looks for 1.in, 2.in, ... 5.in"}
|
| 4 |
+
{"problem_id": "101", "category": "algorithmic", "statement": "Problem Name: Circuit\n\nDescription:\nYou are given a circuit board consisting of N component slots.\nEach slot contains either an AND gate (&) or an OR gate (|). The actual type of each slot is hidden.\nEvery slot was supposed to contain an AND gate, but at most R slots mistakenly contain an OR gate instead.\nYour task is to determine the true type of every slot by interacting with the judge.\n\nSpecifications of the Circuit Board:\n- The board consists of 2N+1 switches numbered 0..2N, each with an ON/OFF state, outputting 0 or 1.\n- The board also consists of N component slots numbered 0..N-1, each outputting 0 or 1.\n- The outputs are determined from the highest index down to 0, according to the following rules:\n * For j = 2N, 2N-1, ..., N:\n - If switch j is OFF, it outputs 0.\n - If switch j is ON, it outputs 1.\n * For j = N-1, N-2, ..., 0:\n - Let the output of slot j be x.\n - If switch j is OFF, it outputs x.\n - If switch j is ON, it outputs 1-x.\n * For i = N-1, N-2, ..., 0:\n - Slot i is connected to two switches Ui, Vi (i < Ui < Vi ≤ 2N).\n - If slot i is AND, it outputs min(output(Ui), output(Vi)).\n - If slot i is OR, it outputs max(output(Ui), output(Vi)).\n\n- For each j = 1..2N, exactly one slot i satisfies Ui=j or Vi=j.\n- The output of the circuit is defined as the output of switch 0.\n\nInteraction:\nAt the beginning of the interaction, the judge prints N and R (the maximum number of OR gates in the hidden circuit), followed by N lines each containing Ui Vi.\nThis describes the wiring of the board. Then your program must interact as follows:\n\n1. Query:\n You may print a line of the form: \"? s\"\n where s is a binary string of length 2N+1. Each character sets the ON/OFF state of the corresponding switch.\n The judge replies with a single line containing 0 or 1, the output of the circuit (switch 0).\n\n2. Answer:\n When you have determined the types of all slots, you must print a line of the form: \"! t\"\n where t is a string of length N, each character being & or |, representing your guess of the hidden circuit.\n If your guess is completely correct, the judge accepts. Otherwise, you receive Wrong Answer.\n\nConstraints:\n- 1 ≤ N ≤ 8000\n- 1 ≤ R ≤ min(N, 120)\n- The hidden circuit contains at most R OR gates (|)\n- i < Ui < Vi ≤ 2N for all 0 ≤ i < N\n- For each j=1..2N, exactly one i satisfies Ui=j or Vi=j\n- At most 5000 queries may be made. Exceeding this limit results in Wrong Answer.\n\nSpecial Requirement:\n- Your program must be written in C++.\n\nSample Interaction:\n\nSuppose the input file contains:\n3 2\n1 4\n2 3\n5 6\n&&|\n\nThe judge first outputs:\n3 2\n1 4\n2 3\n5 6\n\n(Here the hidden true circuit is T = \"&&|\". It has 1 OR gate, which does not exceed R = 2.)\n\nThen the interaction may proceed as follows (lines beginning with '#' are explanations):\n\n? 0001110\n# Player asks a query with binary string s.\n1\n# Judge replies that the circuit output is 1.\n\n? 1111111\n# Another query.\n0\n# Judge replies with 0.\n\n! &&|\n# Player outputs the final answer.\n# The hidden circuit matches the answer, so the judge accepts.\n\n## Scoring\n\nAll feasibility and interaction limits apply before scoring; invalid output receives zero. Points are averaged over test files. For the logarithmic branch, write x for the original minimizing quantity and a for its physical 60-point reference. The improvement factor is r=a/x, and the upper-band award is P=min(100,60+ln(r)). Here ln is natural: r=1 corresponds to 60 points, and on the uncapped logarithmic upper band, r=exp(P-60). Each additional point multiplies the physical improvement factor by e (divides a minimizing objective by e or multiplies a maximizing objective by e, as applicable). The lower-band, zero-objective, and completion rules below still apply.\n\nQ is the number of circuit queries. Define the objective x=Q, its physical reference a=A=900, and the lower-band calculation L=60*max(0,(5000-Q)/4100).\n\n```text\nP = 100, if x = 0\nP = L, if L <= 60 and x > 0\nP = min(100, 60 + ln(r)), otherwise\n```\n\nZero is tested on the valid original count, cost, or error, before the lower-band test. A zero reference anchor has no positive improvement branch; positive objectives keep their lower-band score. The checker reports P/100.\n", "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: 16 # Looks for 1.in, 2.in, ... 5.in"}
|
| 5 |
{"problem_id": "104", "category": "algorithmic", "statement": "Time Limit: 2 s\nMemory Limit: 256 MB\nThis is an interactive problem.\nThere are n students, having roll numbers 1 to n. Mr. 1048576 knows that exactly 1 student is absent today. In order to determine who is absent, he can ask some queries to the class. In each query, he provide two integers l and r (1≤l≤r≤n) and all students whose roll numbers are between l and r (inclusive) are expected to raise their hands.\nBut the students are dishonest. Some students whose roll numbers lie in the given range may not raise their hands, while some other students whose roll number does not lie in the given range may raise their hands. But only the following 4 cases are possible for a particular query (l,r) —\n1. True Positive: r−l+1 students are present and r−l+1 students raised their hands.\n2. True Negative: r−l students are present and r−l students raised their hands.\n3. False Positive: r−l students are present but r−l+1 students raised their hands.\n4. False Negative: r−l+1 students are present but r−l students raised their hands.\nIn the first two cases, the students are said to be answering honestly, while in the last two cases, the students are said to be answering dishonestly. The students can mutually decide upon their strategy, not known to Mr. 1048576. Also, their strategy always meets the following two conditions —\n1. The students will never answer honestly 3 times in a row.\n2. The students will never answer dishonestly 3 times in a row.\nMr. 1048576 is willing to mark at most 2 students as absent (though he knows that only one is). The attendance is said to be successful if the student who is actually absent is among those two. Also, he can only ask up to 2* ⌈log_{1.116}n⌉ queries. Help him complete a successful attendance.\n\nInteraction\nFirst read a line containing a single integer t (1≤t≤2048) denoting the number of independent test cases that you must solve.\nFor each test case, first read a line containing a single integer n (5≤n≤10^5). Then you may ask up to 2* ⌈log_{1.116}n⌉ queries.\nYour score depends on the query count as specified below.\nTo ask a query, print a single line in the format \"? l r\" (without quotes) (1≤l≤r≤n). Then read a single line containing a single integer x (r−l≤x≤r−l+1) denoting the number of students who raised their hands corresponding to the query.\nTo mark a student as absent, print a single line in the format \"! a\" (without quotes) (1≤a≤n). Then read a single integer y (y∈{0,1}). If the student with roll number a was absent, y=1, else, y=0. Note that this operation does not count as a query but you can do this operation at most 2 times.\nTo end a test case, print a single line in the format \"#\" (without quotes). Then you must continue solving the remaining test cases.\nThe sum of n over all test cases does not exceed 10^5.\nTo flush the buffer, use fflush(stdout) or cout.flush()\nThe answer may change depending on your queries but will always remain consistent with the constraints and the answer to the previous queries.\nExample\ninput\n2\n5\n3\n2\n1\n2\n0\n1\n0\n2\n0\n1\n6\n6\n2\n2\n0\n1\n1\n0\n0\n0\n1\noutput\n? 1 4\n? 3 5\n? 2 2\n? 1 3\n? 3 3\n? 3 3\n! 3\n? 2 4\n? 4 4\n! 2\n#\n? 1 6\n? 1 3\n? 4 6\n? 1 1\n? 3 3\n? 5 5\n! 3\n? 2 2\n? 4 4\n! 4\n#\n\n## Scoring\n\nAll feasibility and interaction limits apply before scoring; invalid output receives zero. Points are averaged over test files. For the logarithmic branch, write x for the original minimizing quantity and a for its physical 60-point reference. The improvement factor is r=a/x, and the upper-band award is P=min(100,60+ln(r)). Here ln is natural: r=1 corresponds to 60 points, and on the uncapped logarithmic upper band, r=exp(P-60). Each additional point multiplies the physical improvement factor by e (divides a minimizing objective by e or multiplies a maximizing objective by e, as applicable). The lower-band, zero-objective, and completion rules below still apply.\n\nFor subcase j, let Q_j be its query count and L_j>1 its query limit. Define the per-subcase physical reference a_j=A_j=0.4*L_j+0.6 and B_j=100*min(1,max(0,(L_j-Q_j)/(L_j-1))). Guess actions are not queries.\n\nFor a valid subcase, award 100 if Q_j=0; otherwise award B_j when B_j<=60, and min(100,60+ln(r_j)) when B_j>60, where x_j=Q_j and r_j=a_j/x_j. The file score is the minimum subcase award. A failed subcase gives zero for the file. The checker reports the file score divided by 100.\n", "config": "type: interactive\ntime: 2s\nmemory: 256m\n# A custom checker is required for the special scoring.\nchecker: interactor.cc\nsubtasks:\n - score: 100\n n_cases: 10"}
|
| 6 |
{"problem_id": "106", "category": "algorithmic", "statement": "Hidden Bipartite Graph\n\nThis is an I/O interactive problem. I/O interaction refers to interactive problems, where the program communicates with a special judge during execution instead of producing all output at once. In these problems, the program sends queries (output) to the judge and must immediately read responses (input) before continuing. The solution must strictly follow the input-output protocol defined in the problem statement, because any extra output, missing flush, or incorrect format can cause a wrong answer. Unlike standard problems, interactive problems require careful handling of I/O, synchronization, and flushing to ensure smooth communication between the contestant’s code and the judge.\n\nBob has a simple undirected connected graph (without self-loops and multiple edges). He wants to learn whether his graph is bipartite (that is, you can paint all vertices of the graph into two colors so that there is no edge connecting two vertices of the same color) or not. As he is not very good at programming, he asked Alice for help. He does not want to disclose his graph to Alice, but he agreed that Alice can ask him some questions about the graph.\nThe only question that Alice can ask is the following: she sends s — a subset of vertices of the original graph. Bob answers with the number of edges that have both endpoints in s. Since he doesn't want Alice to learn too much about the graph, he allows her to ask no more than 5000 questions.\nFurthermore, he suspects that Alice might introduce false messages to their communication channel, so when Alice finally tells him whether the graph is bipartite or not, she also needs to provide a proof — either the partitions themselves or a cycle of odd length.\nYour task is to help Alice to construct the queries, find whether the graph is bipartite. Points depend on the number of queries as defined in Scoring.\n\nInput\n\nThe first line contains a single integer n (1 ≤ n ≤ 600) — the number of vertices in Bob's graph.\n\nInteraction\n\nFirst, read an integer n (1≤ n ≤ 600) — the number of vertices in Bob's graph.\nTo make a query, print two lines. First of which should be in the format \"? k\" (1 ≤ k ≤ n), where k is the size of the set to be queried. The second line should contain k space separated distinct integers s1, s2, ..., sk (1 ≤ si ≤ n) — the vertices of the queried set.\n\nAfter each query read a single integer m (0 ≤ m ≤ n(n-1)/2) — the number of edges between the vertices of the set {si}.\nYou are not allowed to ask more than 5000 queries.\n\nIf m = -1, it means that you asked more queries than allowed, or asked an invalid query. Your program should immediately terminate (for example, by calling exit(0)). You will receive Wrong Answer; it means that you asked more queries than allowed, or asked an invalid query. If you ignore this, you can get other verdicts since your program will continue to read from a closed stream.\nAfter printing a query do not forget to print end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:\n\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\nWhen you know the answer, you need to print it.\n\nThe format of the answer depends on whether the graph is bipartite or not.\nIf the graph is bipartite, print two lines. The first should contain the letter \"Y\" (short for \"YES\") followed by a space, and then a single integer s (0 ≤ s ≤ n) — the number of vertices in one of the partitions. Second line should contain s integers a1, a2, ..., as — vertices belonging to the first partition. All ai must be distinct, and all edges in the main graph must have exactly one endpoint in the set {ai}.\nIf the graph is not bipartite, print two lines. The first should contain the letter \"N\" (short for \"NO\") followed by a space, and then a single integer l (3 ≤ l ≤ n) — the length of one simple cycle of odd length. Second line should contain l integers c1, c2, ..., cl — the vertices along the cycle. It must hold that for all 1 ≤ i ≤ l, there is an edge {ci, c_{(i mod l)+1}} in the main graph, and all ci are distinct.\nIf there are multiple possible answers, you may print any of them.\n\nExamples\n\nInput\n\n 4\n 4\n 0\n 1\n 1\n 1\n 0\n\nOutput\n ? 4\n 1 2 3 4\n ? 2\n 1 2\n ? 2\n 1 3\n ? 2\n 1 4\n ? 2\n 2 4\n ? 2\n 3 4\n Y 2\n 1 2\n\nInput\n\n 4\n 4\n 3\n\nOutput\n\n ? 4\n 1 4 2 3\n ? 3\n 1 2 4\n N 3\n 2 1 4\n\nNote\nIn the first case, Alice learns that there are 4 edges in the whole graph. Over the course of the next three queries, she learns that vertex 1 has two neighbors: 3 and 4. She then learns that while vertex 2 is adjacent to 4, the vertex 3 isn't adjacent to 4. There is only one option for the remaining edge, and that is (2, 3). This means that the graph is a cycle on four vertices, with (1, 2) being one partition and (3, 4) being the second.\nHere, it would be also valid to output \"3 4\" on the second line.\nIn the second case, we also have a graph on four vertices and four edges. In the second query, Alice learns that there are three edges among vertices (1, 2, 4). The only way this could possibly happen is that those form a triangle. As the triangle is not bipartite, Alice can report it as a proof. Notice that she does not learn where the fourth edge is, but she is able to answer Bob correctly anyway.\n\n## Scoring\n\nAll feasibility and interaction limits apply before scoring; invalid output receives zero. Points are averaged over test files. For the logarithmic branch, write x for the original minimizing quantity and a for its physical 60-point reference. The improvement factor is r=a/x, and the upper-band award is P=min(100,60+ln(r)). Here ln is natural: r=1 corresponds to 60 points, and on the uncapped logarithmic upper band, r=exp(P-60). Each additional point multiplies the physical improvement factor by e (divides a minimizing objective by e or multiplies a maximizing objective by e, as applicable). The lower-band, zero-objective, and completion rules below still apply.\n\nQ is the number of subset queries, excluding the final answer; the final answer contributes one round to the lower-band formula. Define the objective x=Q, its physical reference a=A=1999, and the lower-band calculation L=100*max(0,1-(Q+1)/5000).\n\n```text\nP = 100, if x = 0\nP = L, if L <= 60 and x > 0\nP = min(100, 60 + ln(r)), otherwise\n```\n\nZero is tested on the valid original count, cost, or error, before the lower-band test. A zero reference anchor has no positive improvement branch; positive objectives keep their lower-band score. The checker reports P/100.\n", "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: 10s\nmemory: 256m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 100 # Looks for 1.in, 2.in, ... 5.in"}
|
| 7 |
{"problem_id": "107", "category": "algorithmic", "statement": "F. Guess Divisors Count\n\ntime limit per test: 2 seconds\nmemory limit per test: 256 megabytes\ninput: standard input\noutput: standard output\n\nThis is an I/O interactive problem. I/O interaction refers to interactive problems, where the program communicates with a special judge during execution instead of producing all output at once. In these problems, the program sends queries (output) to the judge and must immediately read responses (input) before continuing. The solution must strictly follow the input-output protocol defined in the problem statement, because any extra output, missing flush, or incorrect format can cause a wrong answer. Unlike standard problems, interactive problems require careful handling of I/O, synchronization, and flushing to ensure smooth communication between the contestant’s code and the judge.\n\nWe have hidden an integer 1 ≤ X ≤ 10^9. You don't have to guess this number. You have to find the number of divisors of this number, and you don't even have to find the exact number: your answer will be considered correct if its absolute error is not greater than 7 or its relative error is not greater than 0.5.\nMore formally, let your answer be ans and the number of divisors of X be d, then your answer will be considered correct if at least one of the two following conditions is true:\n * | ans - d | ≤ 7;\n * 1/2 ≤ ans / d ≤ 2.\n\nYou can make at most 100 queries. One query consists of one integer 1 ≤ Q ≤ 10^18. In response, you will get gcd(X, Q) — the greatest common divisor of X and Q.\n\nThe number X is fixed before all queries. In other words, interactor is not adaptive.\nLet's call the process of guessing the number of divisors of number X a game. In one test you will have to play T independent games, that is, guess the number of divisors T times for T independent values of X. The score uses the maximum query count across games, as defined in Scoring.\n\nInput\n\nThe first line of input contains one integer T (1 ≤ T ≤ 100) — the number of games.\n\nInteraction\n\nTo make a query print a line \"0 Q\" (1 ≤ Q ≤ 10^18). After that read one integer gcd(X, Q). You can make no more than 100 such queries during one game.\nIf you are confident that you have figured out the number of divisors of X with enough precision, you can print your answer in \"1 ans\" format. ans have to be an integer. If this was the last game, you have to terminate the program, otherwise you have to start the next game immediately. Note that the interactor doesn't print anything in response to you printing answer.\n\nAfter printing a query do not forget to output end of line and flush the output. 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\nExample\nInput (from interactor to you)\n\n 2\n\n 1\n\n 1\n\n 1\n\n 1024\n\n 1048576\n\n 4194304\n\nOutput (from you to interactor)\n\n 0 982306799268821872\n\n 0 230856864650023977\n\n 0 134690134760714371\n\n 1 5\n 0 1024\n\n 0 1048576\n\n 0 1073741824\n\n 1 42\n\nNote\n\nLet's look at the example.\nIn the first game X = 998244353 is hidden. Would be hard to guess this, right? This number is prime, so the number of its divisors is 2. The solution has made several random queries, and all the responses turned out to be 1 (strange things, not even one of three random numbers is divisible by 998244353). It's fare to assume that the hidden number doesn't have many divisors, so the solution has answered 5. Why not. This answer will be considered correct since | 5 - 2 | = 3 ≤ 7.\nIn the second game X = 4,194,304 = 2^22 is hidden, it has 23 divisors. The solution has made queries 1024 = 2^10, 1,048,576 =2^20, 1,073,741,824 = 2^30 and got responses 1024 = 2^10, 1,048,576 =2^20, 4,194,304 = 2^22, respectively. Then the solution got completely confused and answered the answer to The Ultimate Question of Life, the Universe, and Everything.\nThis answer will be considered correct since 1/2 ≤ 42 / 23 ≤ 2.\n\n## Scoring\n\nAll feasibility and interaction limits apply before scoring; invalid output receives zero. Points are averaged over test files. For the logarithmic branch, write x for the original minimizing quantity and a for its physical 60-point reference. The improvement factor is r=a/x, and the upper-band award is P=min(100,60+ln(r)). Here ln is natural: r=1 corresponds to 60 points, and on the uncapped logarithmic upper band, r=exp(P-60). Each additional point multiplies the physical improvement factor by e (divides a minimizing objective by e or multiplies a maximizing objective by e, as applicable). The lower-band, zero-objective, and completion rules below still apply.\n\nQ is the maximum query count across the games in this file; every answer must satisfy the allowed error. Define the objective x=Q, its physical reference a=A=40, and the lower-band calculation L=100*(1-Q/100).\n\n```text\nP = 100, if x = 0\nP = L, if L <= 60 and x > 0\nP = min(100, 60 + ln(r)), otherwise\n```\n\nZero is tested on the valid original count, cost, or error, before the lower-band test. A zero reference anchor has no positive improvement branch; positive objectives keep their lower-band score. Use the maximum count across games, not an average. The checker reports P/100.\n", "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: 2s\nmemory: 256m\n\n# The subtasks section works the same way\nsubtasks:\n - score: 100\n n_cases: 10 # Looks for 1.in, 2.in, ... 5.in"}
|