QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#787502#7878. Matrix DistancesmobbbCompile Error//C++201005b2024-11-27 12:20:442024-11-27 12:20:44

Judging History

你现在查看的是最新测评结果

  • [2024-11-27 12:20:44]
  • 评测
  • [2024-11-27 12:20:44]
  • 提交

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;
}

Details

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){
      |                            ^