#include <bits/stdc++.h>
using namespace std;
int ans[2];
void answer() {
int n, k;
cin >> n >> k;
string s;
cin >> s;
int i = 0, j = n-1;
int index = 1;
while(ans[0] != k && ans[1] != k) {
index = (index +1) % 2;
if(i == j) {
if(s[i] == 'C') {
ans[index]++;
}
continue;
}
char ch1 =s[i], ch2=s[j];
if(ch1 != 'C' && ch2 == 'C') {
i++;
continue;
}
if(ch1 == 'C' && ch2 != 'C') {
j--;
continue;
}
if(ch1 == 'C' && ch2 =='C') {
if(s[i+1] == 'P')
j--;
else i++;
ans[index]++;
}
if(ch1 == 'P' && ch2 =='P'){
if(s[i+1] == 'P'){
i++;
} else j--;
}
index = (index +1) % 2;
}
if(ans[0] >= k){
cout << "NE";
} else
cout << "DA";
}
int main() {
int t=1;
// cin >> t;
while(t--)
answer();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
296 KB |
Output is correct |
6 |
Correct |
0 ms |
296 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |