fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t,lvl;
  8. cin>>t; //l. testow
  9. string ciag;
  10. for(int i=0;i<t;i++) //petla dla liczby testow
  11. {
  12. int u=0,d=0,umax=0,dmax=0;
  13. cin>>lvl; //l poziomow
  14. cin>>ciag; // np. UUDDDP
  15. for(int j=0;j<ciag.length();j++)
  16. {
  17. if(ciag[j]=='U')
  18. {u++;
  19. d=0;
  20. if(u>umax)
  21. {
  22. umax=u;
  23. } //if(umax)
  24. } //if(char=u)
  25. else
  26. {d++;
  27. u=0;
  28. if(d>dmax)
  29. {
  30. dmax=d;
  31. } //if(dmax)
  32. } //else
  33. } //for (j)
  34. if(dmax>=lvl||umax>=lvl) cout<<"NIE"<<endl;
  35. else cout<<"TAK"<<endl;
  36. } //for (i)
  37. } //main
  38.  
Success #stdin #stdout 0s 3472KB
stdin
1
3
UUDUUDUUDUUDUUDUUDUU
stdout
TAK