Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis0
Did not understand the last testcase when t ==7
3 Respostas
+ 2
Share links in description , not in question place, it wont work there..
https://open.kattis.com/problems/basicprogramming1
:
edited
thanks for edit..
+ 1
7.
a. Start from indexĀ i=0;
b. Jump to indexĀ i=A[i]
c. If the current indexĀ iĀ is outside the valid bound of [0..N-1], print āOutā and stop;
d. Else if the current indexĀ i is indexĀ N-1, print āDoneā and stop;
e1. Otherwise, repeat step b;
e2. If doing this leads to an infinite loop, print āCyclicā and stop;
Ā
Sample :
3 7
1 0 4
Here,
A) starts from i=0,
B) i=a[i]= a[0]=1
C) Current index is i<7 ,within the range (else print "out" .)
so
e1) repeat B, i=a[1]=0 so this will get repeated so according to e2: print "cyclic"
D) if(i==7) print done
hope it helps...