103472024-03-31 21:07:14szilHázakcpp17Elfogadva 100/100141ms44936 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct Point {
	ll x, y;
};

struct Line {
	Point a, b;
	int idx;
};

struct Event {
	Point ord;
	Line line;
	bool add;
	int idx;
};

const int MAXN = 100'001;

bool ans[MAXN];

Point operator+(Point a, Point b) {
	return {a.x + b.x, a.y + b.y};
}

Point operator-(Point a, Point b) {
	return {a.x - b.x, a.y - b.y};
}

ll cross(Point a, Point b) {
	return a.x * b.y - a.y * b.x;
}

int forog(Point a, Point b, Point c) {
	ll x = cross(b - a, c - a);
	if (x > 0) return 1;
	if (x == 0) return 0;
	if (x < 0) return -1;
}

bool operator<(const Line &a, const Line &b) {
	return forog(a.a, a.b, b.a) > 0;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vector<Line> lines(n);
	vector<Event> events;
	for (Line &l : lines) {
		cin >> l.a.x >> l.b.y >> l.b.x >> l.a.y;
	}
	
	for (int i = 0; i < n; i++) {
		Event e1, e2;
		e1.line = e2.line = lines[i];
		e1.ord = lines[i].a;
		e2.ord = lines[i].b;
		e1.add = false;
		e2.add = true;
		e1.idx = e2.idx = i;
		events.emplace_back(e1);
		events.emplace_back(e2);
	}

	sort(events.begin(), events.end(), [&](auto a, auto b){
		ll forgas = cross(a.ord, b.ord);
		if (forgas == 0) {
			if (a.add != b.add) return a.add > b.add;
			return a.ord.x*a.ord.x + a.ord.y*a.ord.y < b.ord.x*b.ord.x + b.ord.y*b.ord.y;
		}
		return forgas > 0;
	});

	set<Line> s;
	for (auto [ord, line, add, idx] : events) {
		line.idx = idx;
		if (add) {
			s.insert(line);
		} else {
			auto it = s.find(line);
			assert(it != s.end());
			s.erase(it);
		}
		if (!s.empty()) ans[s.begin()->idx] = true;
	}

	cout << count(ans, ans+MAXN, true) << "\n";
	for (int i = 0; i < n; i++) {
		if (ans[i]) cout << i+1 << " ";
	}
	cout << "\n";

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
subtask10/0
1Elfogadva3ms1832 KiB
2Elfogadva14ms7212 KiB
subtask215/15
3Elfogadva3ms2456 KiB
4Elfogadva4ms2820 KiB
5Elfogadva8ms4836 KiB
6Elfogadva14ms7616 KiB
7Elfogadva14ms7824 KiB
subtask315/15
8Elfogadva3ms3040 KiB
9Elfogadva3ms3444 KiB
10Elfogadva3ms3768 KiB
11Elfogadva3ms3824 KiB
12Elfogadva4ms4336 KiB
subtask420/20
13Elfogadva4ms4480 KiB
14Elfogadva4ms4912 KiB
15Elfogadva8ms6704 KiB
16Elfogadva12ms6980 KiB
17Elfogadva12ms7144 KiB
subtask550/50
18Elfogadva28ms14124 KiB
19Elfogadva37ms14824 KiB
20Elfogadva67ms24672 KiB
21Elfogadva135ms44844 KiB
22Elfogadva141ms44936 KiB