Submission #516819

# Submission time Handle Problem Language Result Execution time Memory
516819 2022-01-22T07:08:37 Z Marslai24 Kamenčići (COCI21_kamencici) C++17
0 / 70
0 ms 204 KB
#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 = 1e5 + 2, K = __lg(N) + 1;

signed main(){
    setIO();
    int n, k;
    string s;
    cin >> n >> k >> s;
    int l = 0, r = n - 1, cnt[2]{};
    for(int i = 0; i < n; i++){
        if(s[l] == 'P')l++;
        else if(s[r] == 'P')r--;
        else{
            cnt[i & 1]++;
            int left = 0, right = 0;
            for(int j = l; j <= r; j++){
                if(s[j] == 'P')break;
                left++;
            }
            for(int j = r; j >= l; j--){
                if(s[j] == 'P')break;
                right++;
            }
            if(left % 2 == 0)l++;
            else r--;
        }
        if(cnt[0] >= k || cnt[1] >= k)break;
    }
    cout << (cnt[0] < k ? "DA" : "NE");
}


# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -