Submission #494217

# Submission time Handle Problem Language Result Execution time Memory
494217 2021-12-14T20:18:47 Z asandikci Kamenčići (COCI21_kamencici) C++17
0 / 70
1 ms 204 KB
#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
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Incorrect 0 ms 204 KB Output isn't correct