이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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--;
}
}
if(ans[0] >= k){
cout << "NE";
} else
cout << "DA";
}
int main() {
int t=1;
// cin >> t;
while(t--)
answer();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |