Task: | Ruudukko |
Sender: | stpn129 |
Submission time: | 2022-11-13 18:09:31 +0200 |
Language: | C++ (C++17) |
Status: | COMPILE ERROR |
Compiler report
In file included from /usr/include/c++/11/ext/pb_ds/detail/type_utils.hpp:47, from /usr/include/c++/11/ext/pb_ds/tag_and_trait.hpp:46, from /usr/include/c++/11/ext/pb_ds/assoc_container.hpp:46, from input/code.cpp:3: /usr/include/c++/11/tr1/type_traits:121:3: error: redefinition of 'struct std::tr1::__is_integral_helper<long long int>' 121 | _DEFINE_SPEC(0, __is_integral_helper, long long, true) | ^ /usr/include/c++/11/tr1/type_traits:117:3: note: previous definition of 'struct std::tr1::__is_integral_helper<long long int>' 117 | _DEFINE_SPEC(0, __is_integral_helper, int, true) | ^ /usr/include/c++/11/tr1/type_traits:122:3: error: redefinition of 'struct std::tr1::__is_integral_helper<long long unsigned int>' 122 | _DEFINE_SPEC(0, __is_integral_helper, unsigned long long, true) | ^ /usr/include/c++/11/tr1/type_traits:118:3: note: previous definition of 'struct std::tr1::__is_integral_helper<long long...
Code
#include <bits/stdc++.h> #define int long long #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; void init_code() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif } const int mod = 1e9+ 7; void solve() { int n; cin >> n; int x; gp_hash_table<int, vector<pair<int, int>> > mp; for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { cin >> x; mp[x].push_back({i, j}); } } int res = 0; map<int, int> isums; map<int, int> jsums; for (auto x : mp) { map<int, int> iadds, jadds; for (auto k : x.second) { int i = k.first; int j = k.second; int val = (isums[i] + jsums[j] + 1) % mod; res = (res + val) % mod; iadds[i] = (iadds[i] + val) ; jadds[j] = (jadds[j] + val) ; } for (auto i: iadds) { isums[i.first] = (isums[i.first] + i.second); } for (auto j: jadds) { jsums[j.first] = (jsums[j.first] + j.second); } } cout << res << '\n'; } signed main() { init_code(); int t = 1; while (t--) { solve(); } return 0; }