#include"iostream"
// #include"vector"
// #include"queue"
// #include"deque"
// #include"set"
// #include"map"
// #include"algorithm"
// #include"cstring"
// #define int long long
using namespace std;
void solve(){
int n,k;
cin >> n >> k;
string str;
cin >> str;
int turn = 1; // 1->Antun(DA) | 2-> Branka(NE)
int red0=0,red1=0;
for(int i=0;i<n;i++){
if(turn==1){
if(str[0]=='P'){
str = str.substr(1,str.length()-1);
}
else if(str[str.length()-1]=='P'){
str = str.substr(0,str.length()-1);
}
else{
str = str.substr(1,str.length()-1);
red1++;
}
if(red1==k){
cout << "NE\n";return;
}
turn=0;
}
else{
if(str[0]=='P'){
str = str.substr(1,str.length()-1);
}
else if(str[str.length()-1]=='P'){
str = str.substr(0,str.length()-1);
}
else{
str = str.substr(1,str.length()-1);
red0++;
}
if(red0==k){
cout << "DA\n";return;
}
turn=1;
}
// cout << str << "\n";
}
}
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
// freopen("","r",stdin);freopen("","w",stdout);
int t=1;
// cin >>t;
for(int i=1;i<=t;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |