Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- using namespace std;
- enum
- {
- MODULO = 4294967161
- };
- inline bool
- is_separator(unsigned a, unsigned b, unsigned c)
- {
- return (a == 0) && (b == 0) && (c == MODULO);
- }
- int
- main()
- {
- map<unsigned, map<unsigned, unsigned>> first_matrix, answer;
- unsigned row, col, value;
- while (cin >> row) {
- cin >> col >> value;
- if (is_separator(row, col, value) == true) {
- break;
- }
- first_matrix[row][col] = value;
- }
- while (cin >> col) {
- cin >> row >> value;
- answer[row][col] = (static_cast<unsigned long long>(answer[row][col]) + static_cast<unsigned long long>(first_matrix[row][col]) * value % MODULO) % MODULO;
- }
- for (auto& row : answer) {
- for (auto& elem : row.second) {
- cout << row.first << " " << elem.first << " " << elem.second << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement