이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"iostream"
// #include"vector"
// #include"queue"
// #include"deque"
// #include"set"
// #include"map"
// #include"algorithm"
// #include"cstring"
// #define int long long
using namespace std;
void solve(){
int n,k;
cin >> n >> k;
string str;
cin >> str;
int turn = 1; // 1->Antun(DA) | 2-> Branka(NE)
int red0=0,red1=0;
for(int i=0;i<n;i++){
if(turn==1){
if(str[0]=='P'){
str = str.substr(1,str.length()-1);
}
else if(str[str.length()-1]=='P'){
str = str.substr(0,str.length()-1);
}
else{
str = str.substr(1,str.length()-1);
red1++;
}
if(red1==k){
cout << "NE\n";return;
}
turn=0;
}
else{
if(str[0]=='P'){
str = str.substr(1,str.length()-1);
}
else if(str[str.length()-1]=='P'){
str = str.substr(0,str.length()-1);
}
else{
str = str.substr(1,str.length()-1);
red0++;
}
if(red0==k){
cout << "DA\n";return;
}
turn=1;
}
// cout << str << "\n";
}
}
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
// freopen("","r",stdin);freopen("","w",stdout);
int t=1;
// cin >>t;
for(int i=1;i<=t;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |