fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner sc=new Scanner(System.in);
  13. int t=sc.nextInt();
  14.  
  15. while(t-->0){
  16.  
  17. String s=sc.next();
  18. int odd=0;
  19. int[] a=new int[26];
  20.  
  21. for(int i=0;i<s.length();i++){
  22. a[s.charAt(i)-97]++;
  23. }
  24. for(int i=0;i<26;i++) if(a[i]%2!=0)odd++;
  25.  
  26. if(odd==2 && s.length()%2==0) System.out.println("DPS");
  27. else if((odd==3 || odd==1) && s.length()%2!=0) System.out.println("DPS");
  28. else System.out.println("!DPS");
  29. }
  30. }
  31. }
Success #stdin #stdout 0.06s 2184192KB
stdin
4
code
xyxyxy
sad
baab
stdout
!DPS
DPS
DPS
!DPS