Submission #1260323

#TimeUsernameProblemLanguageResultExecution timeMemory
1260323am_aadvikTriple Peaks (IOI25_triples)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

bool check(int i, int j, int k, vector<int>& a) {
	if (!((i < j) && (j < k))) return 0;
	if((j < 0) || ((j >= a.size()))) return 0;
	if ((k < 0) || ((k >= a.size()))) return 0;
	if ((i < 0) || ((i >= a.size()))) return 0;
	vector<int> x = { j - i, k - i, k - j };
	vector<int> y = { a[i], a[j], a[k] };
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	for (int i = 0; i < 3; ++i)
		if (x[i] != y[i]) return 0;
	return 1;
}
int find(int i, int k, vector<int>&a) {
	vector<int> op = { i + a[i],
		k - a[i], i + a[k], k - a[k] };
	set<int> s;
	for (auto x : op) s.insert(x);
	int ans = 0;
	for (auto j : s)
		ans += (check(i, j, k, a));
	return ans;
}
int count_triples(vector<int> a) {
	int mx = a[0], ok = 1;
	for (int i = 1; i < a.size(); ++i)
		mx = max(mx, a[i]),
		ok &= (a[i] >= a[i - 1]);

	int ans = 0, n = a.size();
	for (int k = 0; k < n; ++k) {
		int s = (ok ? k - a[k] : 0);
		int e = (ok ? k - a[k] : k - 2);
		for (int i = s; i <= e; ++i)
			ans += find(i, k, a);
	}
	return ans;
}
vector<int> construct_range(int M, int K) {
	vector<int> a; return a;
}
int main() {
	cout << count_triples({ 4, 1, 4, 3, 2, 6, 1 });
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccPhFmAT.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccCfhPn4.o:triples.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status