프로그램 명: ioi_subgraph
제한시간: 1 초
Two undirected graphs G and H are said to be isomorphic if: For example, the next two graphs are isomorphic, even though they look different here:

A possible one-to-one correspondence showing that these two graphs are isomorphic is given by {a-1, b-6, c-8, d-3, g-5, h-2, i-4, j-7}, but others exist too.

A subgraph of a graph G is a graph whose sets of vertices and edges are subsets of those in G. Note that G is a subgraph of itself. The following example shows a graph and one of its subgraphs:

We say that a graph G contains another graph H if there is at least one subgraph H’ of G which is isomorphic to H. The following figure shows a graph G that contains the graph H.

TASK

Given two undirected graphs G and H, produce a subgraph G’ of G such that: Naturally, there may be many subgraphs G’ with the above properties. Produce one of those subgraphs with as many edges as possible.

BASE ALGORITHM

Perhaps the most basic strategy to approach this problem is to consider the edges of G in the order that they are represented in the input file, then attempting to add them one by one to G’, verifying at each step whether H is contained in G’ or not. The correct implementation of this greedy algorithm will earn some points, but much better strategies exist.

CONSTRAINTS

입력

You will be given 10 files forbidden1.in to forbidden10.in each with the following data: forbiddenK.in DESCRIPTION Observe that, except for line 1, the above input represents the adjacency matrices of H and G.

출력

OUTPUT You must provide 10 files, one for each of the inputs. Each file must contain the following data: forbiddenK.out DESCRIPTION #FILE forbidden K Observe that, except for lines 1 and 2, the above output represents the adjacency matrix of G’. Note that there are many possible outputs, and that the above output is correct but not optimal.

입출력 예

입력

3 5
0 1 0
1 0 1
0 1 0
0 1 0 0 0
1 0 1 0 0
0 1 0 1 0
0 0 1 0 1
0 0 0 1 0

출력

5
0 1 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
출처: IOI’06
* 대회 제공 입력 파일은 있는데 .... 출력 파일이 없네요.
[질/답] [제출 현황] [푼 후(0)]
[홈으로]  [뒤 로]