CF1687B.Railway System

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn stations with mm bidirectional tracks connecting them. The ii -th track has length lil_i ( 1li1061\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 2m2m queries. The input of the simulator is a string ss of length mm , consisting of characters 0 and/or 1. The simulator will assume the ii -th track functional if si=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.

输入格式

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

输出格式

Begin the interaction by reading n,mn,m .

To make a query, print "? ss " (without quotes, ss is a string of length mm , 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 "! LL " (without the quotes, LL is the minimum capacity of the system with all tracks functional). Note that giving this answer is not counted towards the limit of 2m2m 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,mn,m ( 2n2002 \leq n \leq 200 , 1m5001\le m \le 500 ) — the number of stations and tracks.

The next mm lines of input must contain exactly 33 space-separated integers uiu_i , viv_i , lil_i ( 1ui,vin1\le u_i,v_i \le n , uiviu_i\ne v_i , 1li1061 \leq l_i \leq 10^6 ) — the endpoints and the length of the ii -th track.

输入输出样例

  • 输入#1

    5 4
    
    0
    
    5
    
    9
    
    7

    输出#1

    ? 0000
    
    ? 1110
    
    ? 1111
    
    ? 1101
    
    ! 7

说明/提示

Here is the graph of the example, satisfying li=il_i=i .

首页