Submission #517036

# Submission time Handle Problem Language Result Execution time Memory
517036 2022-01-22T12:29:35 Z Marslai24 Kamenčići (COCI21_kamencici) C++17
10 / 70
1000 ms 312 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 = 350, K = __lg(N) + 1;

int n, k;
string s;
int pre[N]{};

bool solve(int l = 0, int r = n - 1, int val = 0){
    if(l > r)return val < k;
    int other = pre[n - 1] - pre[r] - (l ? pre[l - 1] : 0) - val;
    return !solve(l + 1, r, other) && !solve(l, r - 1, other);
}

signed main(){
    setIO();
    cin >> n >> k >> s;
    for(int i = 0; i < n; i++){
        pre[i] = (s[i] == 'C') + (i ? pre[i - 1] : 0);
    }
    cout << (solve() ? "DA\n" : "NE\n");
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Execution timed out 1088 ms 204 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Execution timed out 1088 ms 204 KB Time limit exceeded
8 Halted 0 ms 0 KB -