Submission #516876

#TimeUsernameProblemLanguageResultExecution timeMemory
516876Marslai24Kamenčići (COCI21_kamencici)C++17
0 / 70
1 ms204 KiB
#include <bits/stdc++.h> using namespace std; #define int long long // a.k.a. TLE creator #define all(x) x.begin(), x.end() template<class A, class B> istream& operator >>(istream &o, pair<A, B> &x){return o >> x.first >> x.second;} template<class A, class B> ostream& operator <<(ostream &o, pair<A, B> &x){return o << x.first << ' ' << x.second << ' ';} void setIO(){ios::sync_with_stdio(false); cin.tie(0);} const int INF = INT_MAX, MOD = 998244353, N = 1e6 + 2, K = __lg(N) + 1; signed main(){ setIO(); int n, k; string s; cin >> n >> k >> s; int cnt[2]{}, l = 0, r = n - 1; for(int i = 0; i < n && cnt[0] < k && cnt[1] < k; i++){ if(s[l] == 'P')l++; else if(s[r] == 'P')r--; else{ cnt[i & 1]++; int p = 0; for(int j = l + 1; j <= r; j++){ if(s[j] == 'C')break; p++; } if(p != r - l){ for(int j = r; j > l; j--){ if(s[j] == 'C')break; p++; } } if(p & 1)r--; else l++; } } cout << (cnt[0] < k ? "DA" : "NE"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...