fork(1) download
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. /* gets WA, but I don't know why */
  5.  
  6. int main(void) {
  7. int tests;
  8. scanf("%i", &tests);
  9.  
  10. long first_age, first_position, second_age, second_position, positions_between;
  11.  
  12. for(int i = 0; i < tests; i++) {
  13. scanf("%li %li %li %li", &first_age, &first_position, &second_age, &second_position);
  14. positions_between = abs(second_position - first_position) - 1;
  15. printf("%li ", positions_between);
  16. if(positions_between % 3 == 0) {
  17. (first_age > second_age) ? printf("0\n") : printf("-1\n");
  18. } else {
  19. (first_age > second_age) ? printf("-1\n") : printf("0\n");
  20. }
  21.  
  22. }
  23. }
Success #stdin #stdout 0s 4288KB
stdin
11
10 1 9 5
9 5 10 1
1 1 0 10
1 1 0 9
1 1 0 8
0 1 1 10
0 1 1 9
0 1 1 8
1 10 0 1
1 9 0 1
1 8 0 1
stdout
3 0
3 -1
8 -1
7 -1
6 0
8 0
7 0
6 -1
8 -1
7 -1
6 0