FPEvalDataset/LeetCodeProblem
0302
1{2 "id": 2343,3 "name": "count_unguarded_cells_in_the_grid",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/count-unguarded-cells-in-the-grid/",6 "date": "1650067200000",7 "task_description": "You are given two integers `m` and `n` representing a **0-indexed** `m x n` grid. You are also given two 2D integer arrays `guards` and `walls` where `guards[i] = [rowi, coli]` and `walls[j] = [rowj, colj]` represent the positions of the `ith` guard and `jth` wall respectively. A guard can see every cell in the four cardinal directions (north, east, south, or west) starting from their position unless **obstructed** by a wall or another guard. A cell is **guarded** if there is **at least** one guard that can see it. Return_ the number of unoccupied cells that are **not** **guarded**._ **Example 1:** ``` **Input:** m = 4, n = 6, guards = [[0,0],[1,1],[2,3]], walls = [[0,1],[2,2],[1,4]] **Output:** 7 **Explanation:** The guarded and unguarded cells are shown in red and green respectively in the above diagram. There are a total of 7 unguarded cells, so we return 7. ``` **Example 2:** ``` **Input:** m = 3, n = 3, guards = [[1,1]], walls = [[0,1],[1,0],[2,1],[1,2]] **Output:** 4 **Explanation:** The unguarded cells are shown in green in the above diagram. There are a total of 4 unguarded cells, so we return 4. ``` **Constraints:** `1 <= m, n <= 105` `2 <= m * n <= 105` `1 <= guards.length, walls.length <= 5 * 104` `2 <= guards.length + walls.length <= m * n` `guards[i].length == walls[j].length == 2` `0 <= rowi, rowj < m` `0 <= coli, colj < n` All the positions in `guards` and `walls` are **unique**.",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "m = 4, n = 6, guards = [[0,0],[1,1],[2,3]], walls = [[0,1],[2,2],[1,4]]",12 "output": "7 "13 },14 {15 "label": "Example 2",16 "input": "m = 3, n = 3, guards = [[1,1]], walls = [[0,1],[1,0],[2,1],[1,2]]",17 "output": "4 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 59,24 58,25 [26 [27 42,28 529 ],30 [31 25,32 5333 ],34 [35 16,36 5037 ],38 [39 11,40 541 ],42 [43 48,44 5445 ],46 [47 25,48 149 ],50 [51 38,52 153 ],54 [55 54,56 5257 ],58 [59 7,60 761 ],62 [63 14,64 4665 ],66 [67 34,68 369 ],70 [71 1,72 3673 ],74 [75 52,76 3477 ],78 [79 29,80 3781 ],82 [83 9,84 1685 ],86 [87 23,88 3689 ],90 [91 35,92 2893 ],94 [95 22,96 097 ],98 [99 54,100 17101 ],102 [103 41,104 13105 ],106 [107 8,108 10109 ],110 [111 10,112 13113 ],114 [115 20,116 45117 ],118 [119 54,120 47121 ],122 [123 7,124 51125 ],126 [127 47,128 50129 ]130 ],131 [132 [133 27,134 4135 ],136 [137 38,138 50139 ],140 [141 6,142 51143 ],144 [145 4,146 27147 ],148 [149 32,150 9151 ],152 [153 23,154 34155 ],156 [157 38,158 4159 ],160 [161 10,162 24163 ],164 [165 25,166 25167 ],168 [169 5,170 55171 ],172 [173 19,174 54175 ],176 [177 56,178 36179 ],180 [181 22,182 46183 ],184 [185 37,186 32187 ],188 [189 50,190 47191 ],192 [193 46,194 28195 ],196 [197 39,198 25199 ],200 [201 23,202 14203 ],204 [205 34,206 14207 ],208 [209 45,210 14211 ],212 [213 54,214 38215 ],216 [217 1,218 7219 ],220 [221 55,222 45223 ],224 [225 42,226 27227 ],228 [229 57,230 21231 ],232 [233 8,234 34235 ]236 ]237 ],238 "output": 1617239 },240 {241 "input": [242 64,243 66,244 [245 [246 6,247 12248 ],249 [250 52,251 52252 ],253 [254 1,255 58256 ],257 [258 47,259 28260 ],261 [262 37,263 39264 ],265 [266 33,267 29268 ],269 [270 4,271 2272 ],273 [274 41,275 51276 ],277 [278 19,279 48280 ],281 [282 38,283 55284 ],285 [286 63,287 48288 ],289 [290 49,291 3292 ],293 [294 35,295 25296 ],297 [298 15,299 16300 ],301 [302 30,303 41304 ],305 [306 20,307 18308 ],309 [310 51,311 45312 ],313 [314 49,315 27316 ],317 [318 32,319 47320 ],321 [322 22,323 18324 ],325 [326 0,327 46328 ],329 [330 25,331 45332 ],333 [334 27,335 17336 ],337 [338 62,339 45340 ],341 [342 19,343 22344 ],345 [346 53,347 48348 ],349 [350 57,351 12352 ],353 [354 43,355 25356 ],357 [358 29,359 63360 ],361 [362 39,363 55364 ]365 ],366 [367 [368 9,369 38370 ],371 [372 58,373 52374 ],375 [376 18,377 24378 ],379 [380 59,381 53382 ]383 ]384 ],385 "output": 1584386 },387 {388 "input": [389 40,390 8,391 [392 [393 34,394 4395 ],396 [397 3,398 7399 ],400 [401 0,402 2403 ],404 [405 10,406 0407 ],408 [409 18,410 4411 ],412 [413 26,414 5415 ],416 [417 7,418 1419 ],420 [421 39,422 5423 ],424 [425 37,426 5427 ],428 [429 2,430 4431 ],432 [433 33,434 7435 ],436 [437 26,438 1439 ],440 [441 13,442 1443 ],444 [445 26,446 7447 ],448 [449 6,450 7451 ],452 [453 31,454 6455 ],456 [457 31,458 3459 ],460 [461 3,462 2463 ],464 [465 9,466 0467 ],468 [469 5,470 5471 ],472 [473 38,474 2475 ],476 [477 15,478 6479 ],480 [481 21,482 1483 ]484 ],485 [486 [487 3,488 4489 ],490 [491 22,492 5493 ],494 [495 8,496 0497 ],498 [499 27,500 7501 ],502 [503 2,504 5505 ],506 [507 24,508 5509 ],510 [511 38,512 4513 ],514 [515 38,516 7517 ],518 [519 29,520 4521 ],522 [523 29,524 1525 ],526 [527 20,528 1529 ],530 [531 34,532 0533 ],534 [535 23,536 0537 ],538 [539 12,540 3541 ],542 [543 3,544 0545 ],546 [547 17,548 2549 ],550 [551 30,552 5553 ],554 [555 24,556 1557 ],558 [559 35,560 7561 ],562 [563 39,564 7565 ],566 [567 14,568 2569 ],570 [571 4,572 7573 ],574 [575 28,576 1577 ],578 [579 10,580 4581 ],582 [583 1,584 1585 ],586 [587 24,588 0589 ],590 [591 33,592 6593 ],594 [595 13,596 3597 ],598 [599 38,600 5601 ]602 ]603 ],604 "output": 29605 },606 {607 "input": [608 57,609 15,610 [611 [612 22,613 8614 ],615 [616 17,617 9618 ],619 [620 25,621 4622 ],623 [624 40,625 13626 ],627 [628 21,629 3630 ],631 [632 45,633 9634 ],635 [636 36,637 3638 ],639 [640 14,641 12642 ],643 [644 8,645 11646 ],647 [648 26,649 1650 ],651 [652 32,653 11654 ],655 [656 25,657 9658 ],659 [660 32,661 14662 ],663 [664 2,665 10666 ],667 [668 12,669 2670 ],671 [672 22,673 6674 ],675 [676 31,677 12678 ],679 [680 12,681 8682 ],683 [684 43,685 1686 ],687 [688 17,689 10690 ],691 [692 11,693 9694 ],695 [696 46,697 0698 ],699 [700 24,701 6702 ],703 [704 35,705 6706 ],707 [708 46,709 3710 ],711 [712 26,713 12714 ]715 ],716 [717 [718 55,719 12720 ],721 [722 11,723 7724 ],725 [726 2,727 7728 ],729 [730 49,731 13732 ],733 [734 46,735 10736 ],737 [738 22,739 7740 ]741 ]742 ],743 "output": 96744 },745 {746 "input": [747 54,748 7,749 [750 [751 12,752 2753 ]754 ],755 [756 [757 47,758 2759 ],760 [761 44,762 3763 ]764 ]765 ],766 "output": 323767 },768 {769 "input": [770 71,771 91,772 [773 [774 47,775 65776 ],777 [778 22,779 11780 ],781 [782 22,783 75784 ],785 [786 43,787 61788 ],789 [790 58,791 28792 ],793 [794 15,795 14796 ],797 [798 27,799 46800 ],801 [802 13,803 26804 ],805 [806 16,807 22808 ],809 [810 63,811 15812 ],813 [814 49,815 86816 ],817 [818 40,819 22820 ],821 [822 16,823 89824 ],825 [826 32,827 45828 ],829 [830 6,831 32832 ],833 [834 37,835 63836 ],837 [838 47,839 21840 ],841 [842 52,843 72844 ],845 [846 34,847 88848 ],849 [850 48,851 1852 ],853 [854 40,855 52856 ],857 [858 39,859 1860 ],861 [862 48,863 7864 ],865 [866 50,867 38868 ],869 [870 65,871 87872 ],873 [874 9,875 34876 ],877 [878 49,879 24880 ],881 [882 34,883 69884 ],885 [886 10,887 41888 ],889 [890 67,891 14892 ],893 [894 54,895 87896 ],897 [898 50,899 16900 ],901 [902 58,903 81904 ],905 [906 8,907 16908 ],909 [910 27,911 23912 ],913 [914 21,915 44916 ],917 [918 4,919 34920 ],921 [922 7,923 2924 ],925 [926 65,927 86928 ],929 [930 20,931 60932 ]933 ],934 [935 [936 27,937 47938 ],939 [940 15,941 24942 ],943 [944 36,945 4946 ],947 [948 59,949 58950 ],951 [952 24,953 45954 ],955 [956 63,957 31958 ],959 [960 43,961 52962 ],963 [964 41,965 6966 ],967 [968 21,969 28970 ],971 [972 48,973 45974 ],975 [976 58,977 80978 ],979 [980 11,981 60982 ],983 [984 15,985 48986 ],987 [988 45,989 31990 ],991 [992 44,993 8994 ],995 [996 65,997 15998 ],999 [1000 10,1001 121002 ],1003 [1004 46,1005 111006 ],1007 [1008 12,1009 401010 ],1011 [1012 2,1013 231014 ],1015 [1016 2,1017 291018 ],1019 [1020 18,1021 191022 ],1023 [1024 8,1025 391026 ],1027 [1028 33,1029 381030 ],1031 [1032 18,1033 221034 ],1035 [1036 9,1037 531038 ],1039 [1040 27,1041 821042 ],1043 [1044 48,1045 561046 ],1047 [1048 69,1049 361050 ],1051 [1052 21,1053 511054 ],1055 [1056 70,1057 411058 ],1059 [1060 2,1061 191062 ],1063 [1064 18,1065 761066 ],1067 [1068 57,1069 861070 ],1071 [1072 10,1073 381074 ],1075 [1076 46,1077 311078 ],1079 [1080 24,1081 491082 ],1083 [1084 69,1085 691086 ],1087 [1088 6,1089 401090 ],1091 [1092 43,1093 71094 ],1095 [1096 39,1097 91098 ]1099 ]1100 ],1101 "output": 29611102 },1103 {1104 "input": [1105 89,1106 89,1107 [1108 [1109 29,1110 811111 ],1112 [1113 20,1114 781115 ],1116 [1117 29,1118 381119 ],1120 [1121 30,1122 121123 ],1124 [1125 10,1126 31127 ],1128 [1129 16,1130 531131 ],1132 [1133 5,1134 221135 ],1136 [1137 75,1138 321139 ],1140 [1141 70,1142 451143 ],1144 [1145 55,1146 561147 ],1148 [1149 23,1150 121151 ],1152 [1153 45,1154 761155 ],1156 [1157 56,1158 151159 ],1160 [1161 40,1162 461163 ],1164 [1165 57,1166 741167 ],1168 [1169 65,1170 351171 ],1172 [1173 25,1174 271175 ],1176 [1177 27,1178 571179 ],1180 [1181 62,1182 301183 ],1184 [1185 14,1186 441187 ],1188 [1189 67,1190 411191 ]1192 ],1193 [1194 [1195 68,1196 881197 ],1198 [1199 84,1200 78