# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
963098 |
2024-04-14T14:01:07 Z |
anton |
Roads (CEOI20_roads) |
C++17 |
|
268 ms |
15440 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct Point{
int x, y;
int name;
};
Point rot90(Point a){
Point res;
res.y= -a.x;
res.x =a.y;
return res;
}
Point dif(Point& a, Point& b){
Point res;
res.x= b.x-a.x;
res.y = b.y-a.y;
return res;
}
int dot(Point& a, Point& b){
return a.x*b.x+ a.y*b.y;
}
void transform(Point& p, pair<Point, Point> base){
int x= dot(p, base.first);
int y= dot(p, base.second);
p.x =x;
p.y = y;
}
const int MAX_N = 1e5;
pair<Point, Point> pts[MAX_N];
Point initial[2*MAX_N];
signed main(){
int n;
cin>>n;
for(int i = 0; i<n; i++){
Point a, b;
a.name = i*2;
b.name = i*2+1;
cin>>a.x>>a.y>>b.x>>b.y;
initial[i*2] =a;
initial[i*2+1] = b;
pts[i].first= a;
pts[i].second= b;
}
pair<Point, Point> base = { rot90(dif(pts[0].first, pts[0].second)), dif(pts[0].first, pts[0].second)};
for(int i= 0; i<n; i++){
transform(pts[i].first, base);
transform(pts[i].second, base);
//cout<<pts[i].first.x<<" "<<pts[i].first.y<<" "<<pts[i].second.x<<" "<<pts[i].second.y<<endl;
if(pts[i].first.y>pts[i].second.y){
swap(pts[i].first, pts[i].second);
}
}
auto cmp =[&](pair<Point, Point>& a, pair<Point, Point>& b){
if(a.first.x!=b.first.x){
return a.first.x<b.first.x;
}
else{
return a.first.y< b.first.y;
}
};
sort(&pts[0], &pts[n], cmp);
for(int i = 0; i<n-1; i++){
Point a= initial[pts[i].second.name];
Point b= initial[pts[i+1].first.name];
cout<<a.x<<" "<<a.y<<" "<<b.x<<" "<<b.y<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
1 ms |
2392 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
3 ms |
2396 KB |
Output is correct |
4 |
Correct |
28 ms |
4976 KB |
Output is correct |
5 |
Correct |
47 ms |
5212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
4 ms |
2396 KB |
Output is correct |
4 |
Correct |
31 ms |
4920 KB |
Output is correct |
5 |
Correct |
58 ms |
5296 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
4 ms |
2396 KB |
Output is correct |
9 |
Correct |
25 ms |
5208 KB |
Output is correct |
10 |
Correct |
268 ms |
15440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
3 ms |
2396 KB |
Output is correct |
4 |
Correct |
25 ms |
4840 KB |
Output is correct |
5 |
Correct |
47 ms |
5280 KB |
Output is correct |
6 |
Failed |
1 ms |
2396 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 |
1 ms |
2396 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
1 ms |
2392 KB |
Condition failed: "!Cross(S[*pi], S[*pa])" |
2 |
Halted |
0 ms |
0 KB |
- |