Submission #1037988

# Submission time Handle Problem Language Result Execution time Memory
1037988 2024-07-29T11:47:39 Z vjudge1 Roads (CEOI20_roads) C++17
15 / 100
14 ms 2336 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ar array
#define ld long double
 
const int N = 2e5 + 20;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const ld EPS = 1e-9;
 
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,bmi,bmi2,lzcnt,popcnt")

struct Line{
	ar<int, 2> a, b;
	Line(int x, int y, int z, int w){
		a = {x, y}, b = {z, w};
	}
	double get(){
		if(a[0] == b[0])return -a[0];
		return a[1] - a[0] * (1.0 * b[1] - a[1]) / (b[0] - a[0]);
	}
};

bool comp(Line a, Line b){
	if(abs(a.get() - b.get()) >= EPS)return a.get() > b.get();
	return a.a < b.a;
}

signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
	int n;
	cin>>n;
	vector<Line> A;
	for(int i = 0;i < n;i++){
		int x1, y1, x2, y2;
		cin>>x1>>y1>>x2>>y2;
		if(x1 == x2){
			if(y1 > y2)swap(y1, y2), swap(x1, x2);
			else if(x1 > x2)swap(x1, x2), swap(y1, y2);
		}
		A.push_back(Line{x1, y1, x2, y2});
	}
	sort(A.begin(), A.end(), comp);
	for(int i = 1;i < n;i++)cout<<A[i - 1].b[0]<<" "<<A[i-1].b[1]<<" "<<A[i].a[0]<<" "<<A[i].a[1]<<'\n';
}
 
# Verdict Execution time Memory Grader output
1 Failed 0 ms 348 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 6 ms 1500 KB Output is correct
5 Correct 14 ms 2264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 6 ms 1376 KB Output is correct
5 Correct 13 ms 2264 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Failed 1 ms 604 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 360 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 6 ms 1500 KB Output is correct
5 Correct 13 ms 2336 KB Output is correct
6 Failed 0 ms 348 KB Condition failed: "pf == Sline.end() || !Cross(S[*pa], S[*pf])"
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 0 ms 348 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Failed 1 ms 348 KB Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])"
2 Halted 0 ms 0 KB -