Submission #674662

# Submission time Handle Problem Language Result Execution time Memory
674662 2022-12-25T16:50:57 Z vjudge1 Kamenčići (COCI21_kamencici) C++17
0 / 70
0 ms 212 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("Ofast")
 
#define F first
#define S second
#define vi vector<int>
#define vvi vector<vi>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define vvb vector<vb>
#define pb push_back
#define ppb pop_back
#define read(a) for(auto &x:a) cin >> x;
#define print(a) for(auto x:a) cout << x << " "; cout << "\n";
#define vc vector<char>
#define vvc vector<vc>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

#define int long long
#define ld long double
const int INF = 4e18;

int n, k;
string s;
vi pref;

bool win(int l, int r, int cnt){
    if(cnt >= k) return 0;
    int h = pref[n]-(pref[r+1]-pref[l])-cnt;
    if(h >= k) return 1;

    return (!win(l+1, r, h) || !win(l, r-1, h));
}

void solve(){
    cin >> n >> k >> s;
    pref = vi(n+1);

    for(int i=0; i<n; i++)
        pref[i+1] = pref[i]+(s[i] == 'C' ? 1 : 0);

    cout << (win(0, n-1, 0) ? "DA\n" : "NA\n");
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    // #ifndef ONLINE_JUDGE
    //     freopen("in.txt", "r", stdin);
    //     freopen("out.txt", "w", stdout);
    // #endif

    int tt = 1;
    // cin >> tt;
    while(tt--)
        solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -