Python 3   ||   7 lines, bitmap   ||   xx
\n\nclass Solution:\n    def matrixSumQueries(self, n: int, queries: List[List[int]]) -> int:\n\n        rowcol, ans, Seen = [n,n], 0, [0,0]\n\n        for typ,
\n```\nclass Solution:\n    def matrixSumQueries(self, n: int, queries: List[List[int]]) -> int:\n\n        rowcol, ans, Seen = [n,n], 0, [0,0]\n\n        for typ, idx, val in reversed(queries):\n     \n            if Seen[typ]&(1<<idx): continue\n            Seen[typ]|= (1<<idx)\n    \n            ans+= val * rowcol[typ]\n            rowcol[typ^1]-= 1\n\n        return  ans\n```\n[https://leetcode.com/problems/sum-of-matrix-after-queries/submissions/1011786423/](http://)\n\n\n\nI could be wrong, but I think that time complexity is *O*(*N*) and space complexity is *O*(1), in which *N* ~`len(queries)`.
['Python3']