U268895 [USACO11MAR]Graph Discovery G

题目描述

Bessie has a created a puzzle for Farmer John. In front of him there is a lake with N (1

输入格式

This problem is a reactive problem, meaning that instead of reading and writing to a file you will use stdin and stdout (in other words, console input and output) to interact with a grader program. See the input description for important information about interactive problems. At the beginning of execution, the grader program will write a single integer, N, the number of vertices. You will then write lines with one of the following three forms: ```plain R i j U i j Q ``` where R, U, and Q are the characters 'R', 'U', and 'Q', and i and j are integers in the range 1..N. The first sort of query removes the edge between vertices i and j (if it exists). The second undoes the previous removal of an edge between i and j. The third asks whether the graph is connected; after you output Q, the grader will output either 0 (for not connected) or 1 (for connected). When your program is ready to output the graph, you should output a line with the single character 'A', then N lines, each with N characters. The jth number on the ith of these lines should be 1 if vertices i and j are adjacent, and 0 otherwise (a vertex is never adjacent to itself). If you output an incorrect graph at the end, you will receive 0 points. Otherwise, you will receive points based on the number of times you output 'Q'. If you output 'Q' at most 900 times then you will receive 100% of the points. If you output 'Q' K times for some 900 < K R 1 2 | {{1,2}} | | > Q | | | < 1 | | | > U 1 2 | {} | | > R 3 4 | {{3,4}} | | > Q | | | < 1 | | | > R 4 1 | {{3,4}, {4,1}} | | > Q | | | < 0 | | | > U 3 4 | {{4,1}} | | > U 1 4 | {} | | > R 1 2 | {{1,2}} | | > R 2 3 | {{1,2}, {2,3}} | | > Q | | | < 0 | | | > U 3 2 | {{1,2}} | | > R 3 1 | {{1,2}, {3,1}} | | > Q | | | < 0 | | | > U 1 2 | {{3,1}} | | > Q | | | < 1 | | | > U 3 1 | {} | | > R 1 4 | {{1,4}} | | > Q | | | < 0 | | | > A | | | > 0111 | | | > 1010 | | | > 1100 | | | > 1000 | | TIME LIMIT: 2 seconds Interactive programs usually require extra code that causes output to be unbuffered -- to be written in real time instead of buffering for faster (but later) output. Those C/C++ users who use #include should execute this line before any input or output: setlinebuf (stdout); Users of should also use fgets () to read from stdin. Use of scanf is not recommended; do something like this to parse input data: char line[1000]; setlinebuf (stdout); fgets (line, 1000, stdin); sscanf (line, "..format..", &var1, ...); /* if the line contents need to be interpreted */ Those C++ users who use iostream should cout

输出格式