diff --git "a/data/py/test.jsonl" "b/data/py/test.jsonl" deleted file mode 100644--- "a/data/py/test.jsonl" +++ /dev/null @@ -1,200 +0,0 @@ -{"contest_id":"1286","problem_id":"C1","statement":"C1. Madhouse (Easy version)time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThis problem is different with hard version only by constraints on total answers lengthIt is an interactive problemVenya joined a tour to the madhouse; in which orderlies play with patients the following game. Orderlies pick a string ss of length nn, consisting only of lowercase English letters. The player can ask two types of queries: ? l r \u2013 ask to list all substrings of s[l..r]s[l..r]. Substrings will be returned in random order, and in every substring, all characters will be randomly shuffled. ! s \u2013 guess the string picked by the orderlies. This query can be asked exactly once, after that the game will finish. If the string is guessed correctly, the player wins, otherwise he loses. The player can ask no more than 33 queries of the first type.To make it easier for the orderlies, there is an additional limitation: the total number of returned substrings in all queries of the first type must not exceed (n+1)2(n+1)2.Venya asked you to write a program, which will guess the string by interacting with the orderlies' program and acting by the game's rules.Your program should immediately terminate after guessing the string using a query of the second type. In case your program guessed the string incorrectly, or it violated the game rules, it will receive verdict Wrong answer.Note that in every test case the string is fixed beforehand and will not change during the game, which means that the interactor is not adaptive.InputFirst line contains number nn (1\u2264n\u22641001\u2264n\u2264100)\u00a0\u2014 the length of the picked string.InteractionYou start the interaction by reading the number nn.To ask a query about a substring from ll to rr inclusively (1\u2264l\u2264r\u2264n1\u2264l\u2264r\u2264n), you should output? l ron a separate line. After this, all substrings of s[l..r]s[l..r] will be returned in random order, each substring exactly once. In every returned substring all characters will be randomly shuffled.In the case, if you ask an incorrect query, ask more than 33 queries of the first type or there will be more than (n+1)2(n+1)2 substrings returned in total, you will receive verdict Wrong answer.To guess the string ss, you should output! son a separate line.After printing each query, do not forget to flush the output. Otherwise, you will get Idleness limit exceeded. To flush the output, you can use: fflush(stdout) or cout.flush() in C++; System.out.flush() in Java; flush(output) in Pascal; stdout.flush() in Python; see documentation for other languages. If you received - (dash) as an answer to any query, you need to terminate your program with exit code 0 (for example, by calling exit(0)). This means that there was an error in the interaction protocol. If you don't terminate with exit code 0, you can receive any unsuccessful verdict.Hack formatTo hack a solution, use the following format:The first line should contain one integer nn (1\u2264n\u22641001\u2264n\u2264100)\u00a0\u2014 the length of the string, and the following line should contain the string ss.ExampleInputCopy4\n\na\naa\na\n\ncb\nb\nc\n\ncOutputCopy? 1 2\n\n? 3 4\n\n? 4 4\n\n! aabc","tags":["brute force","constructive algorithms","interactive","math"],"code":"import sys, os\n\ninput = sys.stdin.buffer.readline\n\n\n\nn = int(input())\n\na, b = \"?\".encode(), \"!\".encode()\n\nif n == 1:\n\n os.write(1, b\"%s %d %d\\n\" % (a, 1, 1))\n\n s = input().rstrip().decode()\n\n ans = (\"! \" + s).encode()\n\n os.write(1, b\"%s\\n\" % ans)\n\n exit()\n\ncnt1 = [[0] * 26 for _ in range(n + 1)]\n\nos.write(1, b\"%s %d %d\\n\" % (a, 1, n))\n\nfor _ in range(n * (n + 1) \/\/ 2):\n\n s = list(input().rstrip())\n\n c = cnt1[len(s)]\n\n for i in s:\n\n c[i - 97] += 1\n\ncnt2 = [[0] * 26 for _ in range(n + 1)]\n\nos.write(1, b\"%s %d %d\\n\" % (a, 1, n - 1))\n\nfor _ in range(n * (n - 1) \/\/ 2):\n\n s = list(input().rstrip())\n\n c = cnt2[len(s)]\n\n for i in s:\n\n c[i - 97] += 1\n\nans = [-1] * n\n\nc1, c2 = cnt1[n], cnt2[n - 1]\n\nfor i in range(26):\n\n if c1[i] ^ c2[i]:\n\n ans[-1] = i\n\n break\n\nfor i in range(2, (n + 1) \/\/ 2 + 1):\n\n x = [min(j + 1, n - j, i) for j in range(n)]\n\n c = cnt1[i]\n\n for j in range(n):\n\n if ans[j] ^ -1:\n\n c[ans[j]] -= x[j]\n\n for j in range(26):\n\n if c[j] % i:\n\n ans[i - 2] = j\n\n break\n\n x = [min(j + 1, n - 1 - j, i) for j in range(n - 1)]\n\n c = cnt2[i]\n\n for j in range(n - 1):\n\n if ans[j] ^ -1:\n\n c[ans[j]] -= x[j]\n\n for j in range(26):\n\n if c[j] % i:\n\n ans[-i] = j\n\n break\n\nif not n % 2:\n\n c = cnt1[n]\n\n for i in ans:\n\n if i ^ -1:\n\n c[i] -= 1\n\n for i in range(26):\n\n if c[i]:\n\n ans[n \/\/ 2 - 1] = i\n\n break\n\nans = (\"! \" + \"\".join(chr(i + 97) for i in ans)).encode()\n\nos.write(1, b\"%s\\n\" % ans)\n\nexit()","language":"py"} -{"contest_id":"1324","problem_id":"E","statement":"E. Sleeping Scheduletime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVova had a pretty weird sleeping schedule. There are hh hours in a day. Vova will sleep exactly nn times. The ii-th time he will sleep exactly after aiai hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 00). Each time Vova sleeps exactly one day (in other words, hh hours).Vova thinks that the ii-th sleeping time is good if he starts to sleep between hours ll and rr inclusive.Vova can control himself and before the ii-th time can choose between two options: go to sleep after aiai hours or after ai\u22121ai\u22121 hours.Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.InputThe first line of the input contains four integers n,h,ln,h,l and rr (1\u2264n\u22642000,3\u2264h\u22642000,0\u2264l\u2264r