# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447231 | Yahli | Roads (CEOI20_roads) | C++14 | 131 ms | 1844 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using ppi = pair<pi, pi>;
int counter = 0;
void process(vector<ppi> line){
for (int i = 1; i < line.size(); ++i){
cout << line[i-1].second.first << " " << line[i-1].second.second << " " << line[i].first.first << " " << line[i].first.second << endl;
counter++;
}
}
bool cmp(ppi f, ppi s){
if (f.first.second != s.first.second) return f.first.second < s.first.second;
return f < s;
}
int main(){
int n; cin >> n;
vector<ppi> data(n);
for (int i = 0; i < n; ++i){
cin >> data[i].first.first >> data[i].first.second >> data[i].second.first >> data[i].second.second;
if (data[i].first.first > data[i].second.first) swap(data[i].first, data[i].second);
}
sort(data.begin(), data.end(), cmp);
vector<ppi> line;
for (ppi now : data){
if (line.size() == 0 || line[0].first.second == now.first.second) line.push_back(now);
else if (line.size() != 0){
cout << line[0].first.first << " " << line[0].first.second << " " << now.first.first << " " << now.first.second << endl;
counter++;
process(line);
line = vector<ppi>(1, now);
}
else line.push_back(now);
}
process(line);
if (counter != n-1) return -1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |