Submission #692319

# Submission time Handle Problem Language Result Execution time Memory
692319 2023-02-01T10:50:07 Z zeroesandones Mountains (IOI17_mountains) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>
#include "mountains.h"
using namespace std;

using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;

#define fr first
#define sc second
#define pb emplace_back

bool check(pi a, pi b, pi c) {
	// check if c blocks a and b
	ll A = a.sc - b.sc;
	ll B = a.fr - b.fr;
	ll C = a.sc * (b.fr - a.fr) + a.fr * (a.sc - b.sc);

	return A * c.fr + B * c.sc + C > 0;
}

int maximum_deevs(vector<int> y) {
	int n = y.size();
	int ans = 1;

	vector<pi> points(n);

	for(int i = 0; i < n; ++i) {
		points[i] = {i, y[i]};
	}

	bool can_see[n][n] = {};
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			for(int k = i + 1; k < j; ++k) {
				if(check(points[i], points[j], points[k])) {
					can_see[i][j] = true;
					can_see[j][i] = true;
				}
			}
		}
	}

	for(int i = 0; i < (1<<n); ++i) {
		// check if subset is valid
		vi subset;
		for(int j = 0; j < n; ++j) {
			if(i & (1<<j))
				subset.pb(j);
		}

		int m = subset.size();
		bool valid = true;
		for(int j = 0; j < m - 1; ++j) {
			if(!can_see[subset[j]][subset[j + 1]]) {
				valid = false;
				break;
			}
		}

		if(valid)
			ans = max(ans, m);
	}

	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 0 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -