304532: CF863G. Graphic Settings

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Graphic Settings

题意翻译

## 题目描述 最近伊凡买了一台新电脑。他兴奋地打开包装,安装了他最喜欢的游戏。用他的旧电脑,伊万不得不选择最坏的图形设置(因为否则帧速率会很低),但现在他想检查,也许他的新电脑可以表现得很好,即使是最好的图形? 游戏中有M M图形参数。i-th参数可以设置为任意正整数 ,最初设置为bi(b1<=ai)因此有![](https://cdn.luogu.org/upload/vjudge_pic/CF863G/eb6d380211f1972f238d837214ec9b2a791b582f.png)种参数组合不同。伊万可以增加或减少这些参数1;之后,游戏将重新启动新的参数(伊万将有机会检查选择的参数组合)。 伊凡想尝试所有可能的P P组合。另外,他希望在尝试了所有组合后返回到初始设置,因为他认为初始设置在某种程度上最适合他的硬件。但伊万并不想重新开始。 所以他想让你告诉你: 如果有一种方法可以精确地改变P P(每一个改变要么减少或增加1 1个参数),尝试所有可能的组合并返回初始组合,那么伊万想知道这种方法。 否则,如果有一种方法可以精确地对p-1p-1进行更改以尝试所有可能的组合(包括最初的组合),那么伊万想知道这种方法。 帮助伊万,告诉他改变参数的方法! ## 输入输出格式 ### 输入格式: 输入的第一行包含一个整数m(1<=m<=6) 第二行包含m个整数a1 a2 ...am(2<=ai<=1000)保证![](https://cdn.luogu.org/upload/vjudge_pic/CF863G/9c59edbe697431cc03d3ed9f261969af239bf102.png) 第三行包含m个整数b1 b2 ... bm(1<=bi<=ai) ### 输出格式: 如果有一种方法可以精确地进行p次更改(每个更改将某些参数减少或增加1),以尝试所有可能的组合并返回到初始组合,然后在第一行中输出循环。然后P线必须跟随,每一步都要做一个改变。行必须是inc x(将参数x x增加1)或dec x(将其减小)。否则,如果有方法精确地对p-1进行更改以尝试所有可能的组合(包括初始组合),则在第一行中输出路径。然后必须遵循P-1行,每行描述变化的方式与上面提到的相同。否则,输出No.

题目描述

Recently Ivan bought a new computer. Excited, he unpacked it and installed his favourite game. With his old computer Ivan had to choose the worst possible graphic settings (because otherwise the framerate would be really low), but now he wants to check, maybe his new computer can perform well even with the best possible graphics? There are $ m $ graphics parameters in the game. $ i $ -th parameter can be set to any positive integer from $ 1 $ to $ a_{i} $ , and initially is set to $ b_{i} $ ( $ b_{i}<=a_{i} $ ). So there are ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF863G/eb6d380211f1972f238d837214ec9b2a791b582f.png) different combinations of parameters. Ivan can increase or decrease any of these parameters by $ 1 $ ; after that the game will be restarted with new parameters (and Ivan will have the opportunity to check chosen combination of parameters). Ivan wants to try all $ p $ possible combinations. Also he wants to return to the initial settings after trying all combinations, because he thinks that initial settings can be somehow best suited for his hardware. But Ivan doesn't really want to make a lot of restarts. So he wants you to tell the following: - If there exists a way to make exactly $ p $ changes (each change either decreases or increases some parameter by $ 1 $ ) to try all possible combinations and return to initial combination, then Ivan wants to know this way. - Otherwise, if there exists a way to make exactly $ p-1 $ changes to try all possible combinations (including the initial one), then Ivan wants to know this way. Help Ivan by showing him the way to change parameters!

输入输出格式

输入格式


The first line of input contains one integer number $ m $ ( $ 1<=m<=6 $ ). The second line contains $ m $ integer numbers $ a_{1},a_{2},...,a_{m} $ ( $ 2<=a_{i}<=1000 $ ). It is guaranteed that ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF863G/9c59edbe697431cc03d3ed9f261969af239bf102.png). The third line contains $ m $ integer numbers $ b_{1},b_{2},...,b_{m} $ ( $ 1<=b_{i}<=a_{i} $ ).

输出格式


If there is a way to make exactly $ p $ changes (each change either decreases or increases some parameter by $ 1 $ ) to try all possible combinations and return to initial combination, then output Cycle in the first line. Then $ p $ lines must follow, each desribing a change. The line must be either inc x (increase parameter $ x $ by $ 1 $ ) or dec x (decrease it). Otherwise, if there is a way to make exactly $ p-1 $ changes to try all possible combinations (including the initial one), then output Path in the first line. Then $ p-1 $ lines must follow, each describing the change the same way as mentioned above. Otherwise, output No.

输入输出样例

输入样例 #1

1
3
1

输出样例 #1

Path
inc 1
inc 1

输入样例 #2

1
3
2

输出样例 #2

No

输入样例 #3

2
3 2
1 1

输出样例 #3

Cycle
inc 1
inc 1
inc 2
dec 1
dec 1
dec 2

Input

题意翻译

有 $m$ 个正整数参数,第 $i$ 种参数初始为 $b_i$。给定长度为 $m$ 的序列 $a$,其中 $a_i$ 表示第 $i$ 个参数 $\le a_i$。设共有 $p = \prod_{i=1}^{m} a_i$ 种参数序列,每次操作可以把某个参数 $+1$ 或 $-1$: - 若存在一个操作序列,使得恰好 $p$ 次操作后每种参数序列都被经过一次,并且回到原序列,输出这个操作序列; - 否则,若存在一个操作序列,使得恰好 $p-1$ 次操作后每种参数序列都被经过一次(包括初始序列),输出这个操作序列。 $m \le 6$,$2 \le a_i \le 1000$,$1 \le b_i \le a_i$,保证 $p = \prod_{i=1}^{m} a_i \le 10^5$。 *** **输入格式** 第一行包含一个整数 $m$。 第二行包含 $m$ 个整数 $a_i$。 第三行包含 $m$ 个整数 $b_i$。 *** **输出格式** 若两种操作序列都不存在,输出 `No`。 若存在第一种操作序列,第一行输出 `Cycle`;否则输出 `Path`。接下来 $p$ 或 $p-1$ 行,第 $i$ 行描述操作序列的第 $i$ 项。 对于将第 $i$ 个参数 $+1$ 的操作,输出 `inc i`;对于将第 $i$ 个参数 $-1$ 的操作,输出 `dec i`。

加入题单

算法标签: