Комментарии
На aMitkvikramCodeforces 977D Editorial, 8 лет назад
0

There are many ways to solve this problem but your solution is concise. I solved it using dfs.

На vovuhCodeforces Round #490 (Div. 3), 8 лет назад
+2

Check for this test case 5 4 5 1 2 2 3 3 1 4 3

Correct Output: 1

На aMitkvikramCodeforces 977D Editorial, 8 лет назад
0

I have updated the first statement. Note that any power of 2 will be even and any power of 3 will be odd, hence (power of 2) can not be equal to (power of 3).

На aMitkvikramCodeforces 977D Editorial, 8 лет назад
0

Auto comment: topic has been updated by aMitkvikram (previous revision, new revision, compare).

0

Auto comment: topic has been updated by aMitkvikram (previous revision, new revision, compare).

На vovuhРазбор Codeforces Round #479 (Div. 3), 8 лет назад
0

There is only one connected component in the graph.We are searching for component which itself is cycle. Here we see that 1-2-3-4 and 4-5-6 are two cycles in component but component itself is not a cycle so answer is 0 not 2.

На vovuhРазбор Codeforces Round #479 (Div. 3), 8 лет назад
+1

I made some changes in your code. In bool DFS(int idx, int cnt) function you were not checking if idx can be last vertex of sequence, and in the end of same function you should return false. Corrected Solution change at line no. 43 and 58.

На vovuhРазбор Codeforces Round #479 (Div. 3), 8 лет назад
0

If we could prove that every vertex has at most one child. For explanation please refer: 977D expanation.

На vovuhРазбор Codeforces Round #479 (Div. 3), 8 лет назад
0

Read this one once:977D It's okay to not understand everything in beginning.

На vovuhРазбор Codeforces Round #479 (Div. 3), 8 лет назад
+1
На aMitkvikramCodeforces 977D Editorial, 8 лет назад
0

Auto comment: topic has been updated by aMitkvikram (previous revision, new revision, compare).