fork download
  1. import java.util.*;
  2. class Main{
  3. public static void main(String[]args){
  4. Scanner cin=new Scanner(System.in);
  5. String line;
  6. for(;cin.hasNext();){
  7. line=cin.nextLine();
  8. while (true) {
  9. boolean a = true;
  10. for (int b = 0; b < line.length() - 1;) {
  11. int c = Character.getNumericValue(line.charAt(b));
  12. int d = Character.getNumericValue(line.charAt(b + 1));
  13. if (c == d - 1 || c == d + 1) {
  14. line = line.substring(0, c) + line.substring(d + 1, line.length());
  15. a = false;
  16. } else {
  17. b++;
  18. }
  19. }
  20. if (a) {
  21. break;
  22. }
  23. }
  24.  
  25. System.out.println(line);
  26. }
  27. }
  28. }
Time limit exceeded #stdin #stdout 5s 4386816KB
stdin
95422357545868773174
24566191298259441958
34757881545564825469
86423251489513547814
stdout
Standard output is empty