fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int T;
  7. scanf("%d",&T);
  8. while(T--){
  9. int n,m;
  10. scanf("%d%d",&n,&m);
  11. int x,y;
  12. scanf("%d%d",&x,&y);
  13.  
  14. int k;
  15. scanf("%d",&k);
  16.  
  17. long long arr[55][55] = {0};
  18. int block[55][2];
  19.  
  20.  
  21. /// for home to Ani's home
  22. for(int i=0; i<k; i++){
  23. int tx,ty;
  24. scanf("%d%d",&tx,&ty);
  25. arr[tx][ty] = -1;
  26. block[i][0] = tx;
  27. block[i][1] = ty;
  28. }
  29.  
  30. arr[1][1] = 1;
  31. for(int i=2; i<=50; i++){
  32. if(arr[1][i] == -1) arr[1][i] = 0;
  33. else arr[1][i] = arr[1][i-1];
  34.  
  35. if(arr[i][1] == -1) arr[i][1] = 0;
  36. else arr[i][1] = arr[i-1][1];
  37.  
  38. }
  39.  
  40. for(int i=2; i<=51; i++){
  41. for(int j=2; j<51; j++){
  42. if(arr[i][j] == -1) arr[i][j] = 0;
  43. else arr[i][j] = arr[i-1][j] + arr[i][j-1] ;
  44.  
  45. arr[i][j]%=10004;
  46. }
  47. }
  48.  
  49.  
  50.  
  51. /// ans = the ways from home to Ani's home
  52. long long ans = arr[x][y];
  53.  
  54. for(int i=1; i<=52; i++){
  55. for(int j=1; j<52; j++){
  56. arr[i][j] = 0;
  57. }
  58. }
  59. for(int i=0; i<k; i++){
  60. arr[block[i][0]][block[i][1]] = -1;
  61. }
  62.  
  63. arr[x][y] = 1;
  64. for(int i=y+1; i<=50; i++){
  65. if(arr[x][i] == -1) arr[x][i] = 0;
  66. else arr[x][i] = arr[x][i-1];
  67. }
  68. for(int i=x+1; i<=50; i++){
  69. if(arr[i][y] == -1) arr[i][y] = 0;
  70. else arr[i][y] = arr[i-1][y];
  71.  
  72. }
  73. for(int i=x+1; i<=51; i++){
  74. for(int j=y+1; j<51; j++){
  75. if(arr[i][j] == -1) arr[i][j] = 0;
  76. else arr[i][j] = arr[i-1][j] + arr[i][j-1] ;
  77. arr[i][j]%=10004;
  78. }
  79. }
  80.  
  81. printf("%lld\n",(ans*arr[n][m])%10004); /// final result
  82. }
  83.  
  84. return 0;
  85. }
  86.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:24: fatal error: bits/stdc++.h: No such file or directory
compilation terminated.
stdout
Standard output is empty