답안 #516893

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516893 2022-01-22T08:08:17 Z Marslai24 Kamenčići (COCI21_kamencici) C++17
30 / 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 = 1e6 + 2, K = __lg(N) + 1;

int n, k;
string s;

bool solve(int l = 0, int r = n - 1, int me = 0, int op = 0){
    if(me >= k)return false;
    if(op >= k)return true;
    if(l > r)return me < k;
    if(l == r)return me + s[l] < k;
    if(solve(l + 2, r, me + s[l], op + s[l + 1]) && solve(l + 1, r - 1, me + s[l], op + s[r]))return true;
    if(solve(l, r - 2, me + s[r], op + s[r - 1]) && solve(l + 1, r - 1, me + s[r], op + s[l]))return true;
    return false;
}

signed main(){
    setIO();
    cin >> n >> k >> s;
    for(auto &i : s)i = (i == 'C');
    cout << (solve() ? "DA\n" : "NE\n");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 224 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 224 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 25 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 224 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 312 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 25 ms 292 KB Output is correct
13 Correct 782 ms 296 KB Output is correct
14 Execution timed out 1089 ms 204 KB Time limit exceeded
15 Halted 0 ms 0 KB -