Codeforces Round 796 (Div. 2)
E
Railway System
Codeforces
未评级
原题
← DF →
翻译中…

As for the technology in the outside world, it is really too advanced for Gensokyo to even look up to.—Yasaka Kanako, Symposium of Post-mysticism

翻译中…

This is an interactive problem.

翻译中…

Under the direct supervision of Kanako and the Moriya Shrine, the railway system of Gensokyo is finally finished. GSKR (Gensokyo Railways) consists of $n$ stations with $m$ bidirectional tracks connecting them. The $i$-th track has length $l_i$ ($1\le l_i\le 10^6$). Due to budget limits, the railway system may not be connected, though there may be more than one track between two stations.

翻译中…

The value of a railway system is defined as the total length of its all tracks. The maximum (or minimum) capacity of a railway system is defined as the maximum (or minimum) value among all of the currently functional system's full spanning forest.

翻译中…

In brief, full spanning forest of a graph is a spanning forest with the same connectivity as the given graph.

翻译中…

Kanako has a simulator only able to process no more than $2m$ queries. The input of the simulator is a string $s$ of length $m$, consisting of characters 0 and/or 1. The simulator will assume the $i$-th track functional if $s_i=$ 1. The device will then tell Kanako the maximum capacity of the system in the simulated state.

翻译中…

Kanako wants to know the the minimum capacity of the system with all tracks functional with the help of the simulator.

翻译中…

The structure of the railway system is fixed in advance. In other words, the interactor is not adaptive.

翻译中…

Input

翻译中…

The first and only line of input contains two integers $n,m$ ($2 \leq n \leq 200$, $1\le m \le 500$) — the number of stations and tracks.

翻译中…

Interaction

翻译中…

Begin the interaction by reading $n,m$.

翻译中…

To make a query, print "? $s$" (without quotes, $s$ is a string of length $m$, consisting of characters 0 and/or 1). Then you should read our response from standard input — the maximum capacity of the system in the simulated state.

翻译中…

If your program has made an invalid query or has run out of tries, the interactor will terminate immediately and your program will get a verdict Wrong answer.

翻译中…

To give the final answer, print "! $L$" (without the quotes, $L$ is the minimum capacity of the system with all tracks functional). Note that giving this answer is not counted towards the limit of $2m$ queries.

翻译中…

After printing a query do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, 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.
翻译中…

Hacks

翻译中…

The first line of input must contain two integers $n,m$ ($2 \leq n \leq 200$, $1\le m \le 500$) — the number of stations and tracks.

翻译中…

The next $m$ lines of input must contain exactly $3$ space-separated integers $u_i$, $v_i$, $l_i$ ($1\le u_i,v_i \le n$, $u_i\ne v_i$, $1 \leq l_i \leq 10^6$) — the endpoints and the length of the $i$-th track.

翻译中…

Note

翻译中…

Here is the graph of the example, satisfying $l_i=i$.

翻译中…

image

翻译中…

样例

Input #1
5 4

0

5

9

7
Output #1
? 0000

? 1110

? 1111

? 1101

! 7
InputCopy OutputCopy
题目信息
题号
1688E
时间限制
1 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。