fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4. class HelloWorld
  5. {
  6. void check(String s)
  7. { int l=s.length();
  8. int i,j,K;
  9. char ci,cf;
  10. int h1;
  11. int h2;
  12. int fl=0;
  13. if(l%2==0)
  14. {
  15. for(i=0;i<l/2;i++)
  16. { ci=s.charAt(i);
  17. h1=0;
  18. h2=0;
  19. for(K=0;K<l/2;K++)
  20. {
  21. cf=s.charAt(K);
  22. if(ci==cf)
  23. h1++;
  24. }
  25. for(j=l/2;j<l;j++)
  26. {
  27. cf=s.charAt(j);
  28. if(ci==cf)
  29. h2++;
  30.  
  31. }
  32. if(h1!=h2)
  33. {
  34. fl=1;
  35. break;
  36. }
  37.  
  38.  
  39. }
  40. }
  41. else if(l%2!=0){
  42. for(i=0;i<l/2;i++)
  43. { ci=s.charAt(i);
  44. h1=0;
  45. h2=0;
  46. for(K=0;K<l/2;K++)
  47. {
  48. cf=s.charAt(K);
  49. if(ci==cf)
  50. h1++;
  51. }
  52. for(j=l/2+1;j<l;j++)
  53. {
  54. cf=s.charAt(j);
  55. if(ci==cf)
  56. h2++;
  57.  
  58. }
  59. if(h1!=h2)
  60. {
  61. fl=1;
  62. break;
  63. }
  64. h1=0;
  65. h2=0;
  66.  
  67. }
  68. }
  69. if(fl==0)
  70. System.out.println("YES");
  71. else
  72. System.out.println("NO");
  73. }
  74.  
  75. public static void main(String []args)throws IOException{
  76.  
  77. int T,i;
  78. String st;
  79. T=Integer.parseInt(br.readLine());
  80. HelloWorld ob=new HelloWorld();
  81. for(i=1;i<=T;i++)
  82. {
  83. st=br.readLine();
  84. ob.check(st);
  85. }
  86.  
  87. }
  88. }
Runtime error #stdin #stdout #stderr 0.07s 32772KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.NumberFormatException: null
	at java.base/java.lang.Integer.parseInt(Integer.java:620)
	at java.base/java.lang.Integer.parseInt(Integer.java:776)
	at HelloWorld.main(Main.java:81)