Submission #866888

# Submission time Handle Problem Language Result Execution time Memory
866888 2023-10-27T09:25:19 Z 3as8 Kamenčići (COCI21_kamencici) C++14
0 / 70
1 ms 1372 KB
#include <bits/stdc++.h>

#define ll long long
#define endl "\n"
#define fastIO cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false);

#define mid ((l + r) / 2)
#define lChild ((index * 2) + 1)
#define rChild ((index * 2) + 2)

using namespace std;

struct node {
    ll t, a, b;
};

ll dp[351][351];

bool get(string& s, ll l, ll r, ll k, vector<ll>& score, bool round) {

   /* cout<<round + 1<< " => "<<l<<" "<<r<<endl;
    cout<<"Score: "<<score[0]<<" "<<score[1]<<endl;*/

    if(score[0] == k) return false;
    else if(score[1] == k) return true;

    if(dp[l][r] != -1) return dp[l][r];

    bool ans = round;
    score[round] += s[l] == 'C';
    if(!round) ans |= get(s, l + 1, r, k, score, !round);
    else ans &= get(s, l + 1, r, k, score, !round);
    score[round] -= s[l] == 'C';


    score[round] += s[r] == 'C';
    if(!round) ans |= get(s, l, r - 1, k, score, !round);
    else ans &= get(s, l, r - 1, k, score, !round);
    score[round] -= s[r] == 'C';

    return dp[l][r] = ans;
}



void solve(ll _) {

    ll n, k; cin>>n>>k;

    memset(dp, -1, sizeof dp);
    string s; cin>>s;

    vector<ll> scores = {0, 0};
    cout<<(get(s, 0, n - 1, k, scores, 0) ? "DA" : "NE")<<endl;

}

int main() {
    fastIO

    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);

    ll t = 0;  solve(t);
}

Compilation message

Main.cpp: In function 'bool get(std::string&, long long int, long long int, long long int, std::vector<long long int>&, bool)':
Main.cpp:41:21: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   41 |     return dp[l][r] = ans;
      |            ~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Incorrect 1 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Incorrect 1 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1368 KB Output is correct
2 Incorrect 1 ms 1372 KB Output isn't correct
3 Halted 0 ms 0 KB -