Advertisement
cbgcbgcbg

DMOPC '20 Contest 3 P2 - Bob and Parallel-Ks

Feb 1st, 2021
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. using namespace __gnu_pbds;
  4. using namespace std;
  5.  
  6. const int nax = 21, maxx = 2e5+5;
  7. int n, m, k, notes[maxx][nax];
  8. gp_hash_table<int, int> exist[nax];
  9.  
  10. int main() {
  11.     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  12.     cin >> m >> n >> k;
  13.     int ans = 0;
  14.     for (int i = 0; i < m; i++){
  15.         for (int j = 0; j < n; j++){
  16.             cin >> notes[i][j];
  17.             if (j) exist[j-1][notes[i][j-1]] = notes[i][j];
  18.         }
  19.     }
  20.     for (int i = 0; i < m; i++)
  21.         for (int j = 0; j < n-1; j++)
  22.             ans += (exist[j].find(notes[i][j]+k) != exist[j].end()) && (exist[j][notes[i][j]+k] == notes[i][j+1]+k);
  23.     cout << ans << "\n";
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement