Submission #636692

# Submission time Handle Problem Language Result Execution time Memory
636692 2022-08-29T23:32:54 Z rc_catunta Kamenčići (COCI21_kamencici) C++17
30 / 70
1000 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 (jugar(0,antun,branka,l+1,r) and 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 (jugar(0,antun,branka+1,l+1,r) and 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 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 40 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 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 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 40 ms 212 KB Output is correct
13 Execution timed out 1086 ms 212 KB Time limit exceeded
14 Halted 0 ms 0 KB -