Submission #715058

#TimeUsernameProblemLanguageResultExecution timeMemory
715058Gabriel1219Kamenčići (COCI21_kamencici)C++11
0 / 70
1079 ms212 KiB
#include <iostream> using namespace std; int main() { int n, k; cin >> n >> k; string s; cin >> s; int size = s.size(); int ac = 0; int bc = 0; int count = 0; while (bc < k && ac < k && size >= 1) { if (size == 1) { if (s[0] == 'C' && count%2 == 0) { ac++; s.erase(0); } else if (s[0] == 'C' && count%2 == 1) { bc++; s.erase(0); } } if (s[0] == 'C' && s[s.size() - 1] == 'C') { int lengthleft = 0; int lengthright = 0; bool c = false; while (c == false) { if (s[lengthleft+1] != s[0]) lengthleft++; else c = true; } c = false; while (c == false) { if (s[s.size() - lengthright - 2] != s[s.size() - 1]) lengthright++; else c = true; } if (lengthleft%2 == 0) s.erase(0); else if (lengthright%2 == 0) s.erase(s.size() - 1); else s.erase(0); ac++; } else if (s[0] == 'P' && s[s.size() - 1] == 'C') { s.erase(0); s.erase(s.size() - 1); } else if (s[0] == 'C' && s[s.size() - 1] == 'P') { if (count%2 == 0) ac++; else bc++; s.erase(0); } else if (s[0] == 'P' && s[s.size() - 1] == 'C') { if (count%2 == 0) ac++; else bc++; s.erase(); } } if (bc == k) cout << "DA" << endl; else if (ac == k) cout << "NE" << endl; else cout << "NE" << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...