# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
717226 | 2023-04-01T15:13:21 Z | Juan | Kamenčići (COCI21_kamencici) | C++14 | 103 ms | 175460 KB |
#include<bits/stdc++.h> using namespace std; #define pii pair<int, int> #define ff first #define ss second #define all(x) x.begin(), x.end() const int maxn = 355; int dp[maxn][maxn][maxn], v[maxn]; bool solve(int l, int r, int pbs1, int pbs2, int p){ if(dp[l][r][pbs1]!=-1) return dp[l][r][pbs1]; if(pbs1==0 || pbs2==0) return dp[l][r][pbs1] = (pbs2==0); if(p==1){ return dp[l][r][pbs1] = max(solve(l+1, r, pbs1-v[l], pbs2, 2), solve(l, r-1, pbs1-v[r], pbs2, 2)); } else{ return dp[l][r][pbs1] = min(solve(l+1, r, pbs1, pbs2-v[l], 1), solve(l, r-1, pbs1, pbs2-v[r], 1)); } } int main(){ int n, k; cin >> n >> k; for(int i = 0; i < n; i++){ char c; cin >> c; v[i] = (c=='C'); } memset(dp, -1, sizeof dp); if(solve(0, n-1, k, k, 1)) cout << "DA\n"; else cout << "NE\n"; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 175280 KB | Output is correct |
2 | Correct | 63 ms | 175368 KB | Output is correct |
3 | Correct | 63 ms | 175392 KB | Output is correct |
4 | Correct | 63 ms | 175340 KB | Output is correct |
5 | Correct | 71 ms | 175360 KB | Output is correct |
6 | Correct | 65 ms | 175284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 175280 KB | Output is correct |
2 | Correct | 63 ms | 175368 KB | Output is correct |
3 | Correct | 63 ms | 175392 KB | Output is correct |
4 | Correct | 63 ms | 175340 KB | Output is correct |
5 | Correct | 71 ms | 175360 KB | Output is correct |
6 | Correct | 65 ms | 175284 KB | Output is correct |
7 | Correct | 63 ms | 175332 KB | Output is correct |
8 | Correct | 64 ms | 175404 KB | Output is correct |
9 | Correct | 66 ms | 175344 KB | Output is correct |
10 | Correct | 73 ms | 175316 KB | Output is correct |
11 | Correct | 64 ms | 175308 KB | Output is correct |
12 | Correct | 64 ms | 175284 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 175280 KB | Output is correct |
2 | Correct | 63 ms | 175368 KB | Output is correct |
3 | Correct | 63 ms | 175392 KB | Output is correct |
4 | Correct | 63 ms | 175340 KB | Output is correct |
5 | Correct | 71 ms | 175360 KB | Output is correct |
6 | Correct | 65 ms | 175284 KB | Output is correct |
7 | Correct | 63 ms | 175332 KB | Output is correct |
8 | Correct | 64 ms | 175404 KB | Output is correct |
9 | Correct | 66 ms | 175344 KB | Output is correct |
10 | Correct | 73 ms | 175316 KB | Output is correct |
11 | Correct | 64 ms | 175308 KB | Output is correct |
12 | Correct | 64 ms | 175284 KB | Output is correct |
13 | Correct | 71 ms | 175308 KB | Output is correct |
14 | Correct | 103 ms | 175404 KB | Output is correct |
15 | Correct | 74 ms | 175308 KB | Output is correct |
16 | Correct | 85 ms | 175460 KB | Output is correct |
17 | Correct | 78 ms | 175400 KB | Output is correct |
18 | Correct | 71 ms | 175408 KB | Output is correct |