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 int long long // a.k.a. TLE creator
#define all(x) x.begin(), x.end()
template<class A, class B> istream& operator >>(istream &o, pair<A, B> &x){return o >> x.first >> x.second;}
template<class A, class B> ostream& operator <<(ostream &o, pair<A, B> &x){return o << x.first << ' ' << x.second << ' ';}
void setIO(){ios::sync_with_stdio(false); cin.tie(0);}
const int INF = INT_MAX, MOD = 998244353, N = 1e6 + 2, K = __lg(N) + 1;
signed main(){
setIO();
int n, k;
cin >> n >> k;
deque<char> s;
for(int i = 0; i < n; i++){
char c;
cin >> c;
s.push_back(c);
}
int cnt[2]{};
for(int i = 0; i < n; i++){
if(cnt[0] >= k || cnt[1] >= k)break;
if(s.front() == 'P'){
s.pop_front();
}else if(s.back() == 'P'){
s.pop_back();
}else{
cnt[i & 1]++;
s.pop_front();
}
}
cout << (cnt[0] < k ? "DA" : "NE");
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |