Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int solve(const vector<vector<int>> &mat) {
- const int n = mat.size(), m = mat[0].size();
- unordered_map<int, int> mp;
- int ans = 0;
- for (int i = 0; i < n; i++) {
- set<int> st;
- for (int j = 0; j < m; j++) {
- st.insert(mat[i][j]);
- }
- for (int it : st) {
- if (mp[it] == 1) {
- ans++;
- }
- }
- for (int it : st) {
- mp[it]++;
- }
- }
- return ans;
- }
- int main() {
- cerr << solve({ {1, 1, 5, 2, 3}, {4,5,6,4,3}, {9,4,4,1,5} }) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement