fork download
  1. T=int(input()) #No. of test case
  2. a=[]
  3. b=[]
  4. c=[]
  5. f=[]
  6. z=[]
  7. m=[]
  8. R=[]
  9. x1=0
  10. y1=0
  11. x2=0
  12. y2=0
  13. h=0;
  14. temp=0;
  15. e=0;
  16. v=0;
  17.  
  18. while T>0:
  19. f=[]
  20. m=[]
  21.  
  22. n,r=list(map(int,input().split()))
  23.  
  24. l=list(map(int,input().split()))
  25.  
  26. for i in range(n):
  27. R.append(l[i])
  28. z.append(i+1)
  29.  
  30. for i in range(n):
  31. if i+1==n:
  32. break
  33. else:
  34. e=z[i+1]-z[i];
  35. if e==0:
  36. f.append(0)
  37. else:
  38. f.append((R[i+1]-R[i])/e)
  39.  
  40.  
  41. for i in range(r):
  42. x1,x2,y1,y2=list(map(int,input().split()))
  43. v=x2-x1
  44.  
  45. if(v==0):
  46. m.append(0)
  47. else:
  48. m.append((y2-y1)/(x2-x1))
  49.  
  50.  
  51.  
  52. for i in range(len(m)):
  53. temp=int(m[i])
  54. for j in range(len(f)):
  55. if temp==f[j] and j<len(f):
  56. h+=1
  57.  
  58. print(h)
  59. h=0
  60. f.clear()
  61. m.clear()
  62. R.clear()
  63. z.clear()
  64.  
  65. T=T-1
  66.  
  67.  
Success #stdin #stdout 0.02s 9316KB
stdin
1
5 3
1 2 3 4 5
1 2 3 4
2 3 3 3
2 5 7 10
stdout
4
0
4