# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
529887 | 2022-02-23T23:54:45 Z | penguinhacker | Kamenčići (COCI21_kamencici) | C++14 | 71 ms | 168128 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array const int mxN=350; int n, k, dp[mxN][mxN][mxN], p[mxN+1]; string s; bool solve(int i, int j, int a) { //cout << i << " " << j << " " << a << endl; if (dp[i][j][a]!=-1) return dp[i][j][a]; if (a==k) return dp[i][j][a]=0; if (p[n]-p[j+1]+p[i]-a==k) { //cout << "WIN " << i << " " << j << " " << a << endl; return dp[i][j][a]=1; } if ((n-(j-i+1))%2==0) // first player return dp[i][j][a]=solve(i+1, j, a+(s[i]=='C'))||solve(i, j-1, a+(s[j]=='C')); return dp[i][j][a]=solve(i+1, j, a)&&solve(i, j-1, a); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k >> s; for (int i=0; i<n; ++i) p[i+1]=p[i]+(s[i]=='C'); memset(dp, -1, sizeof(dp)); cout << (solve(0, n-1, 0)?"DA":"NE"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 168004 KB | Output is correct |
2 | Correct | 59 ms | 168008 KB | Output is correct |
3 | Correct | 62 ms | 168064 KB | Output is correct |
4 | Correct | 63 ms | 168088 KB | Output is correct |
5 | Correct | 64 ms | 168080 KB | Output is correct |
6 | Correct | 58 ms | 168068 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 168004 KB | Output is correct |
2 | Correct | 59 ms | 168008 KB | Output is correct |
3 | Correct | 62 ms | 168064 KB | Output is correct |
4 | Correct | 63 ms | 168088 KB | Output is correct |
5 | Correct | 64 ms | 168080 KB | Output is correct |
6 | Correct | 58 ms | 168068 KB | Output is correct |
7 | Correct | 62 ms | 168044 KB | Output is correct |
8 | Correct | 62 ms | 168088 KB | Output is correct |
9 | Correct | 69 ms | 167988 KB | Output is correct |
10 | Correct | 62 ms | 167988 KB | Output is correct |
11 | Correct | 64 ms | 168060 KB | Output is correct |
12 | Correct | 58 ms | 168004 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 168004 KB | Output is correct |
2 | Correct | 59 ms | 168008 KB | Output is correct |
3 | Correct | 62 ms | 168064 KB | Output is correct |
4 | Correct | 63 ms | 168088 KB | Output is correct |
5 | Correct | 64 ms | 168080 KB | Output is correct |
6 | Correct | 58 ms | 168068 KB | Output is correct |
7 | Correct | 62 ms | 168044 KB | Output is correct |
8 | Correct | 62 ms | 168088 KB | Output is correct |
9 | Correct | 69 ms | 167988 KB | Output is correct |
10 | Correct | 62 ms | 167988 KB | Output is correct |
11 | Correct | 64 ms | 168060 KB | Output is correct |
12 | Correct | 58 ms | 168004 KB | Output is correct |
13 | Correct | 59 ms | 168096 KB | Output is correct |
14 | Correct | 71 ms | 168128 KB | Output is correct |
15 | Correct | 62 ms | 168004 KB | Output is correct |
16 | Correct | 68 ms | 168044 KB | Output is correct |
17 | Correct | 64 ms | 168092 KB | Output is correct |
18 | Correct | 62 ms | 168036 KB | Output is correct |