Submission #523291

# Submission time Handle Problem Language Result Execution time Memory
523291 2022-02-07T10:41:24 Z MilosMilutinovic Ideal city (IOI12_city) C++14
Compilation error
0 ms 0 KB
//todo
#include <bits/stdc++.h>

using namespace std;

const int N = 100050;
int hP[N];
int vP[N];
int szH[N];
int szV[N];

int DistanceSum(int n int *X, int *Y) {
	map<int, vector<pair<int, int>> x;
	map<int, vector<pair<int, int>> y;
	for (int i = 0; i < n; i++) {
		x[X[i]].push_back({y[i], i});
		y[Y[i]].push_back({x[i], i});
	}
	vector<int> V;
	vector<int> H;
	for (auto v : x) {
		auto vec = v.second;
		sort(vec.begin(), vec.end());
		int sz = (int)vec.size();
		for (int i = 0; i < sz; i++) {
			H.push_back(vec[i].second);
			int ptr = i;
			while(ptr + 1 < sz && vec[ptr + 1].first == vec[ptr].first + 1) {
				ptr += 1;
			}
			for (int j = i; j <= ptr; j++) {
				hP[vec[j].second] = vec[i].second;
				szH[i] += 1;
			}
			i = ptr;
		}
	}
	for (auto v : y) {
		auto vec = v.second;
		sort(vec.begin(), vec.end());
		int sz = (int)vec.size();
		for (int i = 0; i < sz; i++) {
			V.push_back(vec[i].second);
			int ptr = i;
			while(ptr + 1 < sz && vec[ptr + 1].first == vec[ptr].first + 1) {
				ptr += 1;
			}
			for (int j = i; j <= ptr; j++) {
				vP[vec[j].second] = vec[i].second;
				szV[i] += 1;
			}
			i = ptr;
		}
	}
}

int main()
{

	return 0;
}

Compilation message

city.cpp:12:23: error: expected ',' or '...' before 'int'
   12 | int DistanceSum(int n int *X, int *Y) {
      |                       ^~~
city.cpp: In function 'int DistanceSum(int)':
city.cpp:13:34: error: template argument 2 is invalid
   13 |  map<int, vector<pair<int, int>> x;
      |                                  ^
city.cpp:13:34: error: template argument 4 is invalid
city.cpp:14:34: error: template argument 2 is invalid
   14 |  map<int, vector<pair<int, int>> y;
      |                                  ^
city.cpp:14:34: error: template argument 4 is invalid
city.cpp:16:3: error: 'x' was not declared in this scope
   16 |   x[X[i]].push_back({y[i], i});
      |   ^
city.cpp:16:5: error: 'X' was not declared in this scope
   16 |   x[X[i]].push_back({y[i], i});
      |     ^
city.cpp:16:22: error: 'y' was not declared in this scope
   16 |   x[X[i]].push_back({y[i], i});
      |                      ^
city.cpp:17:5: error: 'Y' was not declared in this scope
   17 |   y[Y[i]].push_back({x[i], i});
      |     ^
city.cpp:21:16: error: 'x' was not declared in this scope
   21 |  for (auto v : x) {
      |                ^
city.cpp:38:16: error: 'y' was not declared in this scope
   38 |  for (auto v : y) {
      |                ^
city.cpp:55:1: warning: no return statement in function returning non-void [-Wreturn-type]
   55 | }
      | ^