Submission #673828

#TimeUsernameProblemLanguageResultExecution timeMemory
673828tatoKamenčići (COCI21_kamencici)C++14
10 / 70
1 ms300 KiB
#include <bits/stdc++.h> using namespace std; int ans[2]; void answer() { int n, k; cin >> n >> k; string s; cin >> s; int i = 0, j = n-1; int index = 1; while(ans[0] != k && ans[1] != k) { index = (index +1) % 2; if(i == j) { if(s[i] == 'C') { ans[index]++; } continue; } char ch1 =s[i], ch2=s[j]; if(ch1 != 'C' && ch2 == 'C') { i++; continue; } if(ch1 == 'C' && ch2 != 'C') { j--; continue; } if(ch1 == 'C' && ch2 =='C') { if(s[i+1] == 'P') j--; else i++; ans[index]++; } if(ch1 == 'P' && ch2 =='P'){ if(s[i+1] == 'P'){ i++; } else j--; } index = (index +1) % 2; } if(ans[0] >= k){ cout << "NE"; } else cout << "DA"; } int main() { int t=1; // cin >> t; while(t--) answer(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...