Advertisement
STANAANDREY

itec 2021 pb1

Mar 4th, 2023 (edited)
897
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int solve(const vector<vector<int>> &mat) {
  5.     const int n = mat.size(), m = mat[0].size();
  6.     unordered_map<int, int> mp;
  7.     int ans = 0;
  8.     for (int i = 0; i < n; i++) {
  9.         set<int> st;
  10.         for (int j = 0; j < m; j++) {
  11.             st.insert(mat[i][j]);
  12.         }
  13.  
  14.         for (int it : st) {
  15.             if (mp[it] == 1) {
  16.                 ans++;
  17.             }
  18.         }
  19.         for (int it : st) {
  20.             mp[it]++;
  21.         }
  22.     }
  23.     return ans;
  24. }
  25.  
  26. int main() {
  27.     cerr << solve({ {1, 1, 5, 2, 3}, {4,5,6,4,3}, {9,4,4,1,5} }) << endl;
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement