This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2e5+10;
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
// freopen("shuffle.in","r",stdin);
// freopen("shuffle.out","w",stdout);
int n, k; cin >> n >> k;
vector<char> arr(n+1);
for(int i=1;i<=n;i++) cin >> arr[i];
vector<int> qntR(n+1), qntL(n+2);
qntR[0]=qntL[n+1]=0;
for(int i=1;i<=n;i++){
if(arr[i]=='C') qntR[i]=qntR[i-1]+1;
else qntR[i]=0;
}
for(int i=n;i>=1;i--){
if(arr[i]=='C') qntL[i]=qntL[i+1]+1;
else qntL[i]=0;
}
int temp=0, l=1, r=n, antun=0, branka=0;
while(l<=r){
temp++;
if(arr[l]=='P'){
l++;
continue;
}
else if(arr[r]=='P'){
r--;
continue;
}
if(temp%2==1) antun++;
else branka++;
if(antun>=k){
cout << "NE\n";
return 0;
}
else if(branka>=k){
cout << "DA\n";
return 0;
}
if(qntL[l]>=qntR[r]) l++;
else r--;
}
cout << "DA\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |