Submission #797527

#TimeUsernameProblemLanguageResultExecution timeMemory
797527tlnk07Kamenčići (COCI21_kamencici)C++17
70 / 70
1 ms304 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...