/*
Code written by Talant I.D.
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;
const int mod = 1e9+7;
ll mode(ll a) {
a %= mod;
if (a < 0) a += mod;
return a;
}
ll subt(ll a, ll b) {
return mode(mode(a)-mode(b));
}
ll add(ll a, ll b) {
return mode(mode(a)+mode(b));
}
ll mult(ll a, ll b) {
return mode(mode(a)*mode(b));
}
ll binpow(ll a, ll b) {
ll res = 1;
while (b) {
if (b&1) res = mult(res, a);
a = mult(a, a);
b >>= 1;
}
return res;
}
struct Point {
double x, y;
bool operator < (const Point &other) {
if (x == other.x) return y < other.y;
return x < other.x;
}
};
const int N = 1e5+7;
pair <Point, Point> segments[N];
int n;
double slope(pair <Point, Point> a) {
if (a.first.x == a.second.x) return 1e9;
else return (a.second.y-a.first.y)/(a.second.x-a.first.x);
}
bool subtask1() {
bool flag = 1;
for (int i = 0; i < n; i++) {
if (fabs(segments[i].first.x-segments[i].second.x) > eps) flag = 0;
}
return flag;
}
bool subtask2() {
bool flag = 1;
for (int i = 1; i < n; i++) {
auto a = segments[i-1];
auto b = segments[i];
if (fabs(slope(a)-slope(b)) > eps) flag = 0;
}
return flag;
}
int main() {
do_not_disturb
cin >> n;
for (int i = 0; i < n; i++) {
cin >> segments[i].first.x >> segments[i].first.y >> segments[i].second.x >> segments[i].second.y;
if (segments[i].second.x == segments[i].first.x && segments[i].second.y < segments[i].first.y) swap(segments[i].first, segments[i].second);
else if (segments[i].second.x < segments[i].first.x) swap(segments[i].first, segments[i].second);
}
if (subtask1()) {
vector <Point> allp;
for (int i = 0; i < n; i++) {
allp.pb(segments[i].first);
allp.pb(segments[i].second);
}
sort(all(allp));
for (int i = 3; i < n*2; i += 2) {
if (allp[i].x == allp[i-2].x) {
cout << (ll)allp[i-1].x << ' ' << (ll)allp[i-1].y << ' ' << (ll)allp[i-2].x << ' ' << (ll)allp[i-2].y << endl;
}
else {
cout << (ll)allp[i].x << ' ' << (ll)allp[i].y << ' ' << (ll)allp[i-2].x << ' ' << (ll)allp[i-2].y << endl;
}
}
}
else if (subtask2()) {
auto cmp = [&](pair <Point, Point> a, pair <Point, Point> b) {
if (fabs((a.first.y-a.first.x*slope(a))-(b.first.y-b.first.x*slope(b))) < eps) {
return a.second.x < b.second.x;
}
return a.first.y-a.first.x*slope(a) < b.first.y-b.first.x*slope(b);
};
sort(segments, segments+n, cmp);
for (int i = 1; i < n; i++) {
auto a = segments[i-1];
auto b = segments[i];
if (fabs((a.first.x-a.first.y)-(b.first.x-b.first.y)) < eps) {
cout << (ll)a.second.x << ' ' << (ll)a.second.y << ' ' << (ll)b.first.x << ' ' << (ll)b.first.y << endl;
}
else {
cout << (ll)a.first.x << ' ' << (ll)a.first.y << ' ' << (ll)b.first.x << ' ' << (ll)b.first.y << endl;
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
18 ms |
1332 KB |
Output is correct |
5 |
Correct |
38 ms |
2252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
460 KB |
Output is correct |
4 |
Correct |
18 ms |
1356 KB |
Output is correct |
5 |
Correct |
36 ms |
2240 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Failed |
2 ms |
332 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 |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
4 |
Correct |
18 ms |
1400 KB |
Output is correct |
5 |
Correct |
36 ms |
2244 KB |
Output is correct |
6 |
Incorrect |
1 ms |
204 KB |
Unexpected end of file - int32 expected |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |