251582026-02-18 09:47:42PappMatyasLegmesszebbi rossz sorrendű (35 pont)cpp17Forditási hiba
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct int2
{
	int x;
	int y;
};

const int maxVal = 100000;

int main()
{
	int n;
	cin >> n;
	vector<int> v(n);

	int2 empty(
		-1,
		-1
	);

	vector<int2> p(maxVal * 2 + 1, empty);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
		int index = v[i] + maxVal;
		if (p[index].x == -1)
		{
			p[index].x = i;
		}
		p[index].y = i;
	}

	vector<int2> pos;
	vector<int> posp(maxVal * 2 + 1);

	sort(v.begin(), v.end());


	for (int i = 0; i < n; i++)
	{
		if (i != 0)
		{
			if (v[i] == v[i - 1])
			{
				continue;
			}
		}
		int index = v[i] + maxVal;
		posp[v[i] + maxVal] = pos.size();
		pos.push_back(p[index]);
	}

	int s = pos.size();


	int maxDis = -1;
	int2 save;

	for (int i = n - 1; i >= 0; i--)
	{
		int index = posp[v[i] + maxVal];
		int mVal = pos[index].x;
		for (int j = i - 1; j >= 0; j--)
		{
			int sindex = posp[v[j] + maxVal];
			int sVal = pos[sindex].y;
			if (sVal - mVal > maxDis)
			{
				save.x = p[v[i] + maxVal].x + 1;
				save.y = p[v[j] + maxVal].y + 1;
				maxDis = max(maxDis, sVal - mVal);
			}
		}
	}
	if(maxDis == -1) cout << maxDis;
	else
	{
		cout << save.x << " " << save.y;
	}
}
Forditási hiba
open /var/local/lib/isolate/416/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:24:9: error: no matching function for call to 'int2::int2(int, int)'
   24 |         );
      |         ^
main.cpp:7:8: note: candidate: 'int2::int2()'
    7 | struct int2
      |        ^~~~
main.cpp:7:8: note:   candidate expects 0 arguments, 2 provided
main.cpp:7:8: note: candidate: 'constexpr int2::int2(const int2&)'
main.cpp:7:8: note:   candidate expects 1 argument, 2 provided
main.cpp:7:8: note: candidate: 'constexpr int2::int2(int2&&)'
main.cpp:7:8: note:   candidate expects 1 argument, 2 provided