Repository navigation
Expand file tree
/
Copy pathques2.cpp.txt
More file actions
109 lines (108 loc) · 1.86 KB
/
Copy pathques2.cpp.txt
File metadata and controls
109 lines (108 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <iostream>
using namespace std;
int flag=1;
int check(char c, char d)
{
if(c==d && flag==1)
{
return 1;
}
else
{
return 0;
}
}
char multi(char a, char b)
{
int c=a-b;
if(c==0)
{
flag=flag*-1;
return 49;
}
else
{
if(a-48==1)
{
return b;
}
else if(a=='i')
{
if(b=='j')
return 107;
else
{
flag=flag*-1;
return 106;
}
}
else if(a=='j')
{
if(b=='k')
return 105;
else
{
flag=flag*-1;
return 107;
}
}
else if(a=='k')
{
if(b=='i')
return 106;
else
{
flag=flag*-1;
return 105;
}
}
}
}
int main()
{
int t;
int l, x;
string s;
cin>>t;
for(int i=0; i<t; i++)
{
flag=1;
int k=0, j;
cin>>l>>x;
cin>>s;
char ans=49;
char chek=105;
for(j=0; j<l*x; j++)
{
if(k==l)
{
k=0;
}
ans=multi(ans, s[k]);
if(check(ans, chek)==1)
{
ans=49;
chek++;
}
k++;
if(chek==108)
{
break;
}
}
if(chek==108 && j==(l*x)-1)
{
cout<<"Case #"<<i+1<<":"<<" "<<"YES"<<endl;
}
else
{
cout<<"Case #"<<i+1<<":"<<" "<<"NO"<<endl;
}
//cout<<char(d+1);
//char b=multi(s[0], s[2]);
//cout<<b;
//cout<<flag;
}
// your code goes here
return 0;
}