Submission #1261704

#TimeUsernameProblemLanguageResultExecution timeMemory
1261704gry3125Kamenčići (COCI21_kamencici)C++20
0 / 70
0 ms324 KiB
#include <bits/stdc++.h> #define owo ios_base::sync_with_stdio(0);cin.tie(0); #define all(v) (v).begin(),(v).end() #define pb push_back #define fi first #define se second typedef long long int ll; using namespace std; int main() { owo int n, k; cin >> n >> k; deque<char> c(n); bool t = 1; vector<int> cnt(2); for (int i = 0; i < n; i++) cin >> c[i]; while (c.size() > 1) { t = !t; if (cnt[0] == k) {cout << "NE"; return 0;} if (cnt[1] == k) {cout << "DA"; return 0;} if (c.front() == 'P') {c.pop_front(); continue;} if (c.back() == 'P') {c.pop_back(); continue;} cnt[t]++; if (c[1] == 'C') {c.pop_front(); continue;} if (c[c.size()-2] == 'C') {c.pop_back(); continue;} int L = 0, R = 0; for (int i = 1; i < c.size(); i++) { if (c[i] == 'P') L++; else break; } for (int i = c.size()-2; i >= 0; i--) { if (c[i] == 'P') R++; else break; } if (L < R) c.pop_front(); else c.pop_back(); } if (cnt[0] == k) {cout << "NE"; return 0;} if (cnt[1] == k) {cout << "DA"; return 0;} cout << "NE"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...