답안 #867913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867913 2023-10-29T18:16:07 Z AnasAAF Kamenčići (COCI21_kamencici) C++17
0 / 70
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define float double

bool ans(0);
int n, k;
string s;

void  bk(int L, int R, bool trn, int cA, int cB){
    if(cA>=k)return;
    if(cB>=k){
        ans=1;
        return;
    }
    if(trn){
        if(s[L]=='P'){
            bk(L+1, R, !trn, cA, cB);
        }
        if(s[R]=='P'){
            bk(L, R-1, !trn, cA, cB);
        }
        else if(s[L]=='C' && s[R]=='C'){
            bk(L+1, R, !trn, cA, cB + (s[L]=='C') );
            bk(L, R-1, !trn, cA, cB + (s[R]=='C') );
        }
    }
    else{
        if(s[L]=='P'){
            bk(L+1, R, !trn, cA, cB);
        }
        if(s[R]=='P'){
            bk(L, R-1, !trn, cA, cB);
        }
        else if(s[L]=='C' && s[R]=='C'){
            bk(L+1, R, !trn, cA + (s[L]=='C'), cB );
            bk(L, R-1, !trn, cA + (s[R]=='C'), cB );
        }

    }
    return;

}

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    cin>>s;
    bk(0, n-1, 0, 0, 0);
    if(ans)cout<<"DA"<<endl;
    else cout<<"NE"<<endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -