답안 #636694

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
636694 2022-08-29T23:36:12 Z rc_catunta Kamenčići (COCI21_kamencici) C++17
10 / 70
1 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int n,k;
string s;

bool jugar(int turno, int antun, int branka,int l,int r){
    // Casos Base
    if(antun==k) return false;
    if(branka==k) return true;
    if(s[l]=='P' and s[r]=='P'){
        if(turno==0){
            return (jugar(1,antun,branka,l+1,r) or jugar(1,antun,branka,l,r-1));
        }
        else{
            return not (jugar(0,antun,branka,l+1,r) or jugar(0,antun,branka,l,r-1));
        }
    }
    if(s[l]=='P' and s[r]=='C'){
        if(turno==0){
            return jugar(1,antun,branka,l+1,r);
        }
        else{
            return (jugar(0,antun,branka,l+1,r));
        }
    }
    if(s[l]=='C' and s[r]=='P'){
        if(turno==0){
            return jugar(1,antun,branka,l,r-1);
        }
        else{
            return (jugar(0,antun,branka,l,r-1));
        }
    }
    if(s[l]=='C' and s[r]=='C'){
        if(turno==0){
            return (jugar(1,antun+1,branka,l+1,r) or jugar(1,antun+1,branka,l,r-1));
        }
        else{
            return not (jugar(0,antun,branka+1,l+1,r) or jugar(0,antun,branka+1,l,r-1));
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cin>>n>>k;
    cin>>s;
    if(jugar(0,0,0,0,s.size()-1)) cout<<"DA\n";
    else cout<<"NE\n";
    //cout<<jugar(0,2,1,4,7)<<"\n";
    return 0;
}

Compilation message

Main.cpp: In function 'bool jugar(int, int, int, int, int)':
Main.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
   48 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 1 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -