fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static boolean eqchar(String s)
  8. {
  9. for (int i = 1; i < s.length(); i++)
  10. {
  11. if (s.charAt(i) != s.charAt(0)) return false;
  12. }
  13. return true;
  14. }
  15.  
  16. public static boolean ispal(String s)
  17. {
  18. for (int i = 0; i < s.length()/2; i++)
  19. {
  20. if (s.charAt(i) != s.charAt(s.length() - i - 1)) return false;
  21. }
  22. return true;
  23. }
  24.  
  25. public static void main (String[] args) throws java.lang.Exception
  26. {
  27. Scanner in=new Scanner(System.in);
  28. String s = in.nextLine();
  29. if (eqchar(s)) System.out.println("NO SOLUTION");
  30. else
  31. {
  32. if (!ispal(s)) System.out.println(s);
  33. else
  34. {
  35. if (s.charAt(0) < s.charAt(1)) System.out.println(s.substring(0, s.length() - 1));
  36. else System.out.println(s.substring(1));
  37. }
  38. }
  39. }
  40. }
Success #stdin #stdout 0.13s 29376KB
stdin
abbbba
stdout
abbbb