This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, k;
string s;
void go (int a, int b, int l, int r, int mv) {
//cerr << a << ' ' << b << ' ' << l << ' ' << r << ' ' << mv << '\n';
if (a == k || l >= r) return;
if (b == k) cout << "DA", exit(false);
if (mv) {
if (s[l] == 'P') go(a, b, l+1, r, mv^1);
else if (s[r] == 'P') go(a, b, l, r-1, mv^1);
else if (s[l] == 'C') go(a+1, b, l+1, r, mv^1);
else if (s[r] == 'C') go(a+1, b, l, r-1, mv^1);
} else {
if (s[l] == 'P') go(a, b, l+1, r, mv^1);
else if (s[r] == 'P') go(a, b, l, r-1, mv^1);
else if (s[l] == 'C') go(a, b+1, l+1, r, mv^1);
else if (s[r] == 'C') go(a, b+1, l, r-1, mv^1);
}
}
signed main () {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n >> k >> s;
go(0, 0, 0, n-1, 1);
cout << "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... |