fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int t;
  5. scanf("%d",&t);
  6. while(t>0)
  7. {
  8. char st[4];
  9. int ch,rep[100],count=0,i;
  10. scanf("%s",&st);
  11. for(i=0; i<4; i++)
  12. {
  13. ch=st[i];
  14. if(rep[ch]==3)
  15. count=3;
  16. else if(rep[ch]==2)
  17. count=2;
  18. else if(rep[ch]==1)
  19. count=1;
  20. else
  21. count=1;
  22.  
  23. rep[ch]++;
  24.  
  25. }
  26. if(count==3)
  27. printf("-1\n");
  28. else if(count==2)
  29. printf("6\n");
  30. else if(count==1)
  31. printf("4\n");
  32. t--;
  33. }
  34. }
Success #stdin #stdout 0.01s 5320KB
stdin
3
0000
9876
3313
stdout
4
4
4