//Coded by Chirath Nirodha
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define P push
#define I insert
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll mod=1e9+7;
inline void io(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
void solve(){
io();
int n,k;cin>>n>>k;
string s;cin>>s;
int a=0,b=n-1;
int x=0,y=0;
bool aut=true;
while(a<=b){
int tt=0;
if(s[a]=='P')a++;
else if(s[b]=='P')b--;
else{
if(aut)x++;
else y++;
if(b-a<3)a++;
else{
if(a+1=='C')a++;
else b++;
}
}
if(x==k){cout<<"NE"<<endl;return;}
if(y==k){cout<<"DA"<<endl;return;}
if(aut)aut=false;
else aut=true;
}
}
int main(){
io();
solve();
//int t;cin>>t;for(int i=0;i<t;i++)solve();
return 0;
}
Compilation message
Main.cpp: In function 'void solve()':
Main.cpp:30:7: warning: unused variable 'tt' [-Wunused-variable]
30 | int tt=0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |