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;
long long n, m[2], l, r;
bool turn = 0;
string s;
int main()
{
cin >> n >> m[0] >> s;
m[1] = m[0];
l = 0; r = n - 1;
while(l <= r && m[0] > 0 && m[1] > 0)
{
if(s[l] == 'P') ++l;
else if(s[r] == 'P') --r;
else
{
--m[turn];
long long temp1 = 0, temp2 = 0;
while(s[l + temp1] != 'P' && temp1 + l < n - 1) ++temp1;
while(s[r - temp2] != 'P' && r - temp2 > 1) ++temp2;
if(temp1 >= temp2) ++l;
else --r;
}
turn = 1 - turn;
}
if(m[0] == 0) cout << "NE";
else cout << "DA";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |