Codeforces Beta Round 27(Codeforces 格式,Div. 2)
D
Ring Road 2
Codeforces
2200
原题
← CE →

Ring Road 2AI (CI翻译)

It is well known that Berland has $*n*$ cities, which form the Silver ring — cities $*i*$ and $*i* + 1$ ($1 ≤ *i* < *n*$) are connected by a road, as well as the cities $*n*$ and $1$. The goverment have decided to build $*m*$ new roads. The list of the roads to build was prepared. Each road will connect two cities. Each road should be a curve which lies inside or outside the ring. New roads will have no common points with the ring (except the endpoints of the road).

{"titleZh":"环路 2","bodyZh":"众所周知,Berland 有 $*n*$ 座城市,它们构成一个银环:城市 $*i*$ 和 $*i* + 1$($1 ≤ *i* < *n*$)之间有一条道路,城市 $*n*$ 和城市 $1$ 之间也有一条道路。政府决定新建 $*m*$ 条道路,并已制定好待建道路的清单。每条新道路连接两座城市,并且应是一条位于环内或环外的曲线。新道路与银环没有公共点(道路端点除外)。AI (CI翻译)

Now the designers of the constructing plan wonder if it is possible to build the roads in such a way that no two roads intersect (note that the roads may intersect at their endpoints). If it is possible to do, which roads should be inside the ring, and which should be outside?

现在,规划人员想知道,是否能以一种方式修建这些道路,使得任意两条道路都不相交(注意,道路可以在端点处相交)。如果可以,哪些道路应位于环内,哪些应位于环外?AI (CI翻译)

Input

输入格式

AI (CI翻译)

The first line contains two integers $*n*$ and $*m*$ ($4 ≤ *n* ≤ 100, 1 ≤ *m* ≤ 100$). Each of the following $*m*$ lines contains two integers $*a*_{*i*}$ and $*b*_{*i*}$ ($1 ≤ *a*_{*i*}, *b*_{*i*} ≤ *n*, *a*_{*i*} ≠ *b*_{*i*}$). No two cities will be connected by more than one road in the list. The list will not contain the roads which exist in the Silver ring.

第一行包含两个整数 $*n*$ 和 $*m*$($4 ≤ *n* ≤ 100, 1 ≤ *m* ≤ 100)。接下来的 $m$ 行,每行包含两个整数 $a{i}$ 和 $b{i}$($1 ≤ a{i}, b{i} ≤ n, a{i} ≠ b{i}$)。清单中任意两座城市之间至多有一条待建道路。清单中不会包含银环上已有的道路。AI (CI翻译)

Output

输出格式

AI (CI翻译)

If it is impossible to build the roads in such a way that no two roads intersect, output Impossible. Otherwise print $*m*$ characters. $*i*$-th character should be i, if the road should be inside the ring, and o if the road should be outside the ring. If there are several solutions, output any of them.

如果无法以任意两条道路都不相交的方式修建这些道路,输出 Impossible。否则,输出一个长度为 $*m*$ 的字符串。第 $*i*$ 个字符应为 i,表示第 $*i*$ 条道路应位于环内;若应位于环外,则输出 o。如果有多种方案,输出任意一种。"}AI (CI翻译)

样例

Input #1
4 2
1 3
2 4
Output #1
io
InputCopy OutputCopy
Input #2
6 3
1 3
3 5
5 1
Output #2
ooo
InputCopy OutputCopy
题目信息
题号
27D
时间限制
2 s
内存限制
256 MB
标签
2-SAT
DFS 及类似
并查集
图论

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