fork download
  1. #pragma warning(disable:4996)
  2. #include "stdio.h"
  3. #include "stdlib.h"
  4. #include "string.h"
  5.  
  6. struct list
  7. {
  8. struct list* next;
  9. char name[30];
  10. int number;
  11. };
  12.  
  13.  
  14. int main()
  15. {
  16. struct list dictionary[26][26][26] = { {NULL,{0},0} };
  17. struct list *input;
  18. struct list *pool = (struct list*)calloc(sizeof(struct list) * 100000, sizeof(struct list));
  19. int pool_used = 0;
  20. int index_number;
  21. char name[30] = { 0 };
  22. scanf("%d", &index_number);
  23. for (int i = 0; i < index_number; i++)
  24. {
  25. scanf("%s", &name);
  26. input = &dictionary[name[0] - 97][name[1] - 97][name[2] - 97];
  27. while (input->number != 0)
  28. {
  29. if (input->next == 0 && pool_used < 100000)
  30. {
  31. input->next = &pool[pool_used++];
  32. }
  33. input = input->next;
  34. }
  35. scanf("%d", &input->number);
  36. strncpy(input->name, name, 30);
  37. }
  38. while (scanf("%s", &name) != EOF)
  39. {
  40. input = &dictionary[name[0] - 97][name[1] - 97][name[2] - 97];
  41. while (input->next != NULL)
  42. {
  43. if (strncmp(name, input->name, 30) == 0)
  44. {
  45. break;
  46. }
  47. input = input->next;
  48. }
  49.  
  50. if((strncmp(name, input->name, 30) != 0))printf("Not found\n");
  51. else printf("%s=%d\n", name, input->number);
  52.  
  53. }
  54. free(pool);
  55. return 0;
  56. }
Success #stdin #stdout 0.08s 227068KB
stdin
Standard input is empty
stdout
Standard output is empty