fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(){
  5.  
  6. // TO DO: 각각의 단어들에서 글자들을 뽑아낸 후, 서로 비교하여 같은 글자들이 있으면 오캐이
  7. int test;
  8. scanf("%d", &test);
  9.  
  10. int go = 0;
  11. while(go < test){
  12. // 단어 두개 입력받기
  13. char word1[1001];
  14. char word2[1001];
  15.  
  16. scanf("%s %s", word1, word2);
  17.  
  18.  
  19. int alpha[26] = {0};
  20. int length1 = strlen(word1);
  21. int length2 = strlen(word2);
  22. int check = 0;
  23.  
  24. if(length1 == length2)
  25. check = 1;
  26.  
  27. if(check){
  28. int i, j;
  29. for(i = 0 ; i < length1 ; i++){
  30. alpha[word1[i]-'a']++;
  31. }
  32.  
  33. for(j = 0 ; j < length2 ; j++){
  34. if(alpha[word2[j]-'a'] != 0){
  35. alpha[word2[j]-'a'] = -1;
  36. }
  37. }
  38.  
  39. int count = 0;
  40. for(i = 0 ; i < 26 ; i++){
  41. if(alpha[i] == -1)
  42. count++;
  43. //printf("%c: %d ", i+'a' ,alpha[i]);
  44. }
  45.  
  46. if(count == length1){
  47. printf("Possible\n");
  48. } else{
  49. printf("Impossible\n");
  50. }
  51. } else{
  52. printf("Impossible\n");
  53. }
  54. go++;
  55. }
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0s 5304KB
stdin
1
aa aa
stdout
Impossible