답안 #556473

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
556473 2022-05-03T08:33:23 Z new_acc Kamenčići (COCI21_kamencici) C++14
30 / 70
22 ms 26196 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=400+10;
const int SS=1<<19;
const int INFi=2e9;
const ll INFl=1e13;
const ll mod2=998244353;
const ll mod=1e9+7;
const ll mod3=1000696969;
const ll p=70032301;
const ull p2=913;
const int L=20;
bool dp[N][N][N];
void solve(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    s="#"+s;
    int il=0;
    for(int i=1;i<=n;i++) il+=(s[i]=='C');
    for(int i=n;i>=1;i--){
        int curr=0;
        for(int j=i;j<=n;j++){
            curr+=(s[j]=='C');
            for(int __curr=0;__curr<min(j-i+1,k);__curr++){
                int on=il-curr-__curr;
                if(on>=k){
                    dp[i][j][__curr]=1;
                    continue;
                } 
                if(__curr+(s[i]=='C')<k and !dp[i+1][j][on]) dp[i][j][__curr]=1;
                if(__curr+(s[j]=='C')<k and !dp[i][j-1][on]) dp[i][j][__curr]=1;
            }
        }
    }
    cout<<(dp[1][n][0]?"DA":"NE")<<"\n";
}
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    int tt=1;
    while(tt--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 992 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 844 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 992 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 980 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 844 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 12 ms 26196 KB Output is correct
14 Correct 16 ms 26128 KB Output is correct
15 Correct 11 ms 23764 KB Output is correct
16 Correct 19 ms 25764 KB Output is correct
17 Incorrect 22 ms 25992 KB Output isn't correct
18 Halted 0 ms 0 KB -