fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void) {
  5. int a[200001];
  6. int b[200001];
  7. int c[200001];
  8.  
  9. int x;
  10. scanf("%d", &x);
  11.  
  12.  
  13. int *hash_table = calloc(x+1, sizeof(int));
  14. for (int i = 0; i < x; i++) {
  15. scanf("%d", &a[i]);
  16. hash_table[a[i]] = i + 1;
  17. }
  18.  
  19. for (int i = 0; i < x; i++) {
  20. scanf("%d", &b[i]);
  21. c[i] = hash_table[b[i]];
  22. }
  23.  
  24.  
  25. printf("%d ", c[0]);
  26. int max = c[0];
  27. for (int i = 1; i < x; i++) {
  28. int diff = c[i] - max;
  29. if (diff <= 0) {
  30. printf("0 ");
  31. } else {
  32. printf("%d ", diff);
  33. max = c[i];
  34. }
  35. }
  36. printf("\n");
  37.  
  38. free(hash_table);
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 5508KB
stdin
Standard input is empty
stdout
0