Submission #867913

#TimeUsernameProblemLanguageResultExecution timeMemory
867913AnasAAFKamenčići (COCI21_kamencici)C++17
0 / 70
1 ms348 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...