Advertisement
filashkov

Untitled

Apr 21st, 2021
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3.  
  4. using namespace std;
  5.  
  6. enum
  7. {
  8.     MODULO = 4294967161
  9. };
  10.  
  11. inline bool
  12. is_separator(unsigned a, unsigned b, unsigned c)
  13. {
  14.     return (a == 0) && (b == 0) && (c == MODULO);
  15. }
  16.  
  17. int
  18. main()
  19. {
  20.     map<unsigned, map<unsigned, unsigned>> first_matrix, answer;
  21.     unsigned row, col, value;
  22.     while (cin >> row) {
  23.         cin >> col >> value;
  24.         if (is_separator(row, col, value) == true) {
  25.             break;
  26.         }
  27.         first_matrix[row][col] = value;
  28.     }
  29.  
  30.     while (cin >> col) {
  31.         cin >> row >> value;
  32.         answer[row][col] = (static_cast<unsigned long long>(answer[row][col]) + static_cast<unsigned long long>(first_matrix[row][col]) * value % MODULO) % MODULO;
  33.     }
  34.  
  35.     for (auto& row : answer) {
  36.         for (auto& elem : row.second) {
  37.             cout << row.first << " " << elem.first << " " << elem.second << endl;
  38.         }
  39.     }
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement