QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#787502 | #7878. Matrix Distances | mobbb | Compile Error | / | / | C++20 | 1005b | 2024-11-27 12:20:44 | 2024-11-27 12:20:44 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::unorder_map<int, std::vector<int>> x, y;
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
int c;
std::cin >> c;
x[c].push_back(i);
y[c].push_back(j);
}
}
ll ans = 0;
for (auto [c, v] : x){
int m = v.size();
std::sort(v.begin(), v.end());
std::vector<ll> suf(m + 1);
for (int i = m - 1; i >= 0; i--){
suf[i] = suf[i + 1] + v[i];
}
for (int i = 0; i < m; i++){
ans += i * v[i] - (suf[0] - suf[i]) + suf[i] - (m - i) * v[i];
}
}
for (auto [c, v] : y){
int m = v.size();
std::sort(v.begin(), v.end());
std::vector<ll> suf(m + 1);
for (int i = m - 1; i >= 0; i--){
suf[i] = suf[i + 1] + v[i];
}
for (int i = 0; i < m; i++){
ans += i * v[i] - (suf[0] - suf[i]) + suf[i] - (m - i) * v[i];
}
}
std::cout << ans << '\n';
return 0;
}
詳細信息
answer.code: In function ‘int main()’: answer.code:12:14: error: ‘unorder_map’ is not a member of ‘std’; did you mean ‘unordered_map’? 12 | std::unorder_map<int, std::vector<int>> x, y; | ^~~~~~~~~~~ | unordered_map answer.code:12:26: error: expected primary-expression before ‘int’ 12 | std::unorder_map<int, std::vector<int>> x, y; | ^~~ answer.code:17:25: error: ‘x’ was not declared in this scope 17 | x[c].push_back(i); | ^ answer.code:18:25: error: ‘y’ was not declared in this scope 18 | y[c].push_back(j); | ^ answer.code:22:28: error: ‘x’ was not declared in this scope 22 | for (auto [c, v] : x){ | ^ answer.code:33:28: error: ‘y’ was not declared in this scope 33 | for (auto [c, v] : y){ | ^