经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Problem B: Octagons

📝 题解 🔵 仅限 C++
题目描述
<p></p> <h2>Problem B: Octagons</h2> <p>Below is a picture of an infinite hyperbolic tessellation of octagons. If we think of this as a graph of vertices (of degree three), then there exists an isomorphism of the graph which maps any vertex <i>x</i> onto any other vertex <i>y</i>. Every edge is given a label from the set <i>{a,b,c}</i> in such a way that every vertex has all three types of edges incident on it, and the labels alternate around each octagon. Part of this labeling is illustrated in the diagram.</p> <p><img src="http://tk.hustoj.com/admin/../upload/pimg28250_1.png" alt="" /></p> <p>So a path in this graph (starting from any vertex) can be specified by a sequence of edge labels. Your job is to write a program which, given a squence of labels such as &quot;abcbcbcabcaccabb&quot;, returns &quot;closed&quot; if the path ends on the same vertex where it starts, and returns &quot;open&quot; otherwise.</p>
输入格式
<p>The input will begin with a number <i>Z</i> &le; 200 on a line by itself. This is followed by <i>Z</i> lines, each of which is a squence of length at least 1 and at most 40 of 'a's 'b's and 'c's.</p>
输出格式
<p>For each input instance, the output will be the words &quot;closed&quot; or &quot;open&quot;, each on a single line.</p>
样例
样例输入 1
2 abababab abcbcbcbcba
样例输出 1
closed open
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用