-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path735A - Ostap and Grasshopper.cpp
85 lines (74 loc) · 1.54 KB
/
735A - Ostap and Grasshopper.cpp
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
#include<bits/stdc++.h>
using namespace std;
// Code Written By: Vikash Patel
int main()
{
int n,k;
cin>>n>>k;
string s;
cin>>s;
int g,t;
int c1=0,c2=0;
for(int i=0;i<n;i++)
{
if(s[i]=='G')
{
g=i;
c1++;
}
if(s[i]=='T')
{
t=i;
c2++;
}
if(c1==1 && c2==1)
{
break;
}
}
int x=0,y=0;
if(g<t)
{
for (int i=g; i<=t; i+=k)
{
if (s[i] == '#')
{
y = 1;
cout << "NO" << endl;
break;
}
else if (s[i] == 'T')
{
y = 1;
cout << "YES" << endl;
break;
}
else if (s[i] != 'T')
x = 0;
}
if (x == 0 && y == 0)
cout << "NO" << endl;
}
else
{
for (int i=t; i<=g; i+=k)
{
if (s[i] == '#')
{
y = 1;
cout << "NO" << endl;
break;
}
else if (s[i] == 'G')
{
y = 1;
cout << "YES" << endl;
break;
}
else if (s[i] != 'G')
x = 0;
}
if (x == 0 && y == 0)
cout << "NO" << endl;
}
}