File tree 2 files changed +123
-0
lines changed
2 files changed +123
-0
lines changed Original file line number Diff line number Diff line change
1
+ //CodeChef problem : Temple Land(SNAKQL17)
2
+ //Problem Code : SNAKPROC
3
+ //Author : Piyush
4
+ #include <stdio.h>
5
+ #include <string.h>
6
+ int main ()
7
+ {
8
+ int t ,no ,i ,j ,k ,l ,count ;
9
+ char str [502 ],str1 [502 ];
10
+ scanf ("%d" ,& t );
11
+ while (t -- )
12
+ {
13
+ scanf ("%d" ,& no );
14
+ scanf ("%s" ,str );
15
+ i = 0 ;
16
+ k = 0 ;
17
+ for (i = 0 ;i < no ;i ++ )
18
+ {
19
+ str1 [i ]== '.' ;
20
+ }
21
+ for (i = 0 ;i < no ;i ++ )
22
+ {
23
+ if (str [i ]!= '.' )
24
+ {
25
+ str1 [k ]= str [i ];
26
+ k ++ ;
27
+ }
28
+ }
29
+ count = 0 ;
30
+ if (k %2 == 0 )
31
+ {
32
+ if (k == 0 )
33
+ printf ("Valid\n" );
34
+ else
35
+ {
36
+ for (i = 0 ;i < k ;i = i + 2 )
37
+ {
38
+
39
+ if (str1 [i ]== 'H' && str1 [i + 1 ]== 'T' )
40
+ count ++ ;
41
+ else
42
+ {
43
+ count = -1 ;
44
+ break ;
45
+ }
46
+ }
47
+ if (count == (k /2 ))
48
+ printf ("Valid\n" );
49
+ else
50
+ printf ("Invalid\n" );
51
+ }
52
+ }
53
+ else
54
+ {
55
+ printf ("Invalid\n" );
56
+ }
57
+ }
58
+ return 0 ;
59
+ }
Original file line number Diff line number Diff line change
1
+ //CodeChef Problem : Temple Land(SNCKQL17)
2
+ //Problem Code : TEMPLELA
3
+ //Author : Piyush
4
+ #include <stdio.h>
5
+ int main ()
6
+ {
7
+ int t ,l ,no [100 ],i ,count ;
8
+ scanf ("%d" ,& t );
9
+ while (t -- )
10
+ {
11
+ scanf ("%d" ,& l );
12
+ for (i = 0 ;i < l ;i ++ )
13
+ {
14
+ scanf ("%d" ,& no [i ]);
15
+ }
16
+ if (l %2 == 0 )
17
+ printf ("no\n" );
18
+ else
19
+ {
20
+ if (no [0 ]!= 1 )
21
+ printf ("no\n" );
22
+ else
23
+ {
24
+ count = 0 ;
25
+ for (i = 1 ;i < l /2 ;i ++ )
26
+ {
27
+ if (no [i ]== (no [i - 1 ]+ 1 ))
28
+ count ++ ;
29
+ else
30
+ {
31
+ count = -1 ;
32
+ break ;
33
+ }
34
+ }
35
+ if (count == -1 )
36
+ printf ("no\n" );
37
+ else
38
+ {
39
+ if (no [l /2 ]> no [(l /2 )- 1 ])
40
+ {
41
+ count = 0 ;
42
+ for (i = l /2 + 1 ;i < l ;i ++ )
43
+ {
44
+ if (no [i ]== (no [i - 1 ]- 1 ))
45
+ count ++ ;
46
+ else
47
+ {
48
+ count = -1 ;
49
+ break ;
50
+ }
51
+ }
52
+ if (count == -1 )
53
+ printf ("no\n" );
54
+ else
55
+ printf ("yes\n" );
56
+ }
57
+ else
58
+ printf ("no\n" );
59
+ }
60
+ }
61
+ }
62
+ }
63
+ return 0 ;
64
+ }
You can’t perform that action at this time.
0 commit comments