Nondeterministic Finite Automaton

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

A nondeterministic finite automaton (NFA) is defined as G=(V,E_0,E_1,v_0,F)G = (V, E\_0, E\_1, v\_0, F), where (V,E_0)(V, E\_0) and (V,E_1)(V, E\_1) form two directed graphs, v_0Vv\_0 \in V is the initial vertex, and FVF \subseteq V is the set of accepting vertices.

We say that NFA GG recognizes a 0101-string s=s_1s_2s_ns = s\_1 s\_2 \ldots s\_n if and only if there exists a sequence of vertices u_0,u_1u_nu\_0, u\_1 \ldots u\_n such that u_0=v_0u\_0 = v\_0, the edges u_i1,u_iE_s_i\langle u\_{i - 1}, u\_{i} \rangle \in E\_{s\_i} for all i=1,2,,ni = 1, 2, \ldots, n, and u_nFu\_n \in F.

Define L=L(G)L = L(G) as the minimal non-negative integer such that there exists a string ss of length LL which GG can not recognize. If no such LL exists for GG, we define L(G)=1L(G) = -1.

You are given nn, and you need to construct an NFA G=(V,E_0,E_1,v_0,F)G = (V, E\_0, E\_1, v\_0, F) such that V=n|V| = n and L(G)L(G) is large enough. The exact constraints on nn and L(G)L(G) are at the bottom.

입력

The first line of input contains an integer nn.

출력

Output the NFA GG you found.

Suppose the vertices in VV are labeled by integers 0,1,,n10, 1, \ldots, n - 1.

Firstly, output E_0E\_0 in the following format: The first line contains an integer e=E_0e = |E\_0| (0e10000 \le e \le 1000). Then ee lines follow. The ii-th of them contains two integers x_ix\_i and y_iy\_i (0x_i,y_i<n0 \le x\_i, y\_i < n), indicating that there is an edge x_i,y_iE_0\langle x\_i, y\_i \rangle \in E\_0. Note that x_i=y_ix\_i = y\_i is allowed.

Secondly, print E_1E\_1 in the same format as E_0E\_0.

Next, print a line with the integer kk.

After that, print a line containing kk integers f_1,f_2,,f_kf\_1, f\_2, \ldots, f\_k, indicating that F=f_1,f_2,,f_kF = \\{f\_1, f\_2, \ldots, f\_k\\}.

The initial vertex v_0v\_0 is assumed to be 00.

힌트

This problem has two tests: n=6n = 6 and n=20n = 20.

When n=6n = 6, your output's L(G)L(G) should be strictly greater than 1818.

When n=20n = 20, your output's L(G)L(G) should be strictly greater than 400400.