103392024-03-31 20:24:19szilHázakcpp17Wrong answer 0/100214ms53960 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

struct Point {
	ll x, y;
};

struct Line {
	Point a, b;
};

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) {
	if (cross(a.a, a.b)) {
		return forog(a.a, a.b, b.a) > 0 || forog(a.a, a.b, b.b) > 0;
	} else {
		return forog(a.b, a.a, b.a) > 0 || forog(a.b, a.a, b.b) > 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){
		int forgas = cross(a.ord, b.ord);
		if (forgas == 0) {
			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<pair<Line, int>> s;
	for (auto [ord, line, add, idx] : events) {
		if (add) s.insert({line, idx});
		else s.erase({line, idx});
		if (!s.empty()) ans[s.begin()->second] = 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;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1836 KiB
2Wrong answer17ms6796 KiB
subtask20/15
3Accepted3ms2548 KiB
4Wrong answer4ms2976 KiB
5Wrong answer9ms4992 KiB
6Wrong answer17ms7856 KiB
7Wrong answer18ms8408 KiB
subtask30/15
8Accepted3ms3876 KiB
9Wrong answer3ms3944 KiB
10Wrong answer3ms4116 KiB
11Wrong answer3ms4156 KiB
12Wrong answer4ms4652 KiB
subtask40/20
13Accepted4ms4896 KiB
14Wrong answer4ms4972 KiB
15Wrong answer12ms6896 KiB
16Wrong answer16ms8096 KiB
17Wrong answer14ms8252 KiB
subtask50/50
18Wrong answer32ms14256 KiB
19Wrong answer54ms18588 KiB
20Wrong answer98ms28252 KiB
21Wrong answer214ms50764 KiB
22Wrong answer211ms53960 KiB