# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
791583 |
2023-07-24T07:41:52 Z |
peteza |
Roads (CEOI20_roads) |
C++14 |
|
35 ms |
1500 KB |
#include <bits/stdc++.h>
using namespace std;
int n, xx1, yy1, xx2, yy2;
using pii = pair<int, int>;
struct line {
pii a, b;
line(int ax, int ay, int bx, int by){a={ax,ay};b={bx,by};}
double gety() {
if(a.first == b.first) return -a.first;
return a.second - a.first*(1.00*b.second-a.second)/(b.first-a.first);
}
};
vector<line> lns;
ostream& operator<<(ostream& os, pii a) {
os << a.first << ' ' << a.second;
return os;
}
int main() {
cin >> n;
for(int i=0;i<n;i++) {
cin >> xx1 >> yy1 >> xx2 >> yy2;
if(xx1 == xx2) {
if(yy1 > yy2) swap(yy1, yy2);
} else {
if(xx1 > xx2) swap(xx1, xx2);
}
lns.emplace_back(xx1, yy1, xx2, yy2);
}
sort(lns.begin(), lns.end(), [](line a, line b){
//if(a.a.first == 3 && a.a.second == 4 && b.a.first == 1 && b.a.second == 2) cout << a.gety() << ' ' << b.gety() << '\n';
if(abs(a.gety()-b.gety())>=1e-6) return a.gety() > b.gety();
return a.a < b.a;
});
for(int i=1;i<lns.size();i++) cout << lns[i-1].b << ' ' << lns[i].a << '\n';
}
Compilation message
roads.cpp: In function 'int main()':
roads.cpp:38:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<line>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for(int i=1;i<lns.size();i++) cout << lns[i-1].b << ' ' << lns[i].a << '\n';
| ~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Failed |
0 ms |
212 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 |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
17 ms |
840 KB |
Output is correct |
5 |
Correct |
27 ms |
1328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
17 ms |
812 KB |
Output is correct |
5 |
Correct |
27 ms |
1232 KB |
Output is correct |
6 |
Failed |
0 ms |
212 KB |
Condition failed: "iA != P2I.end()" |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
14 ms |
840 KB |
Output is correct |
5 |
Correct |
35 ms |
1500 KB |
Output is correct |
6 |
Failed |
0 ms |
212 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 |
212 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 |
212 KB |
Condition failed: "pf == Sline.end() || !Cross(S[*pi], S[*pf])" |
2 |
Halted |
0 ms |
0 KB |
- |