# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404247 | joelau | 레이저 센서 (KOI16_laser) | C++14 | 2 ms | 300 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;
int N;
pair<int,int> ans[1000];
tuple<int,int,int> lst[3000];
vector< pair<int,int> > v;
int main() {
scanf("%d", &N);
for (int i = 0; i < N; ++i) {
int x,y; scanf("%d %d", &x, &y);
lst[i] = make_tuple(x,0,i);
}
for (int i = 0; i < N*2; ++i) {
int x,y; scanf("%d %d", &x, &y);
lst[i+N] = make_tuple(x,1,i+1);
}
sort(lst,lst+N*3);
for (int i = 0; i < N*3; ++i) {
if (v.size() >= 2 && get<1>(lst[i]) + v.back().first + v[v.size()-2].first == 2) {
if (get<1>(lst[i]) == 0) ans[get<2>(lst[i])] = make_pair(v.back().second, v[v.size()-2].second);
if (v.back().first == 0) ans[v.back().second] = make_pair(get<2>(lst[i]), v[v.size()-2].second);
if (v[v.size()-2].first == 0) ans[v[v.size()-2].second] = make_pair(get<2>(lst[i]), v.back().second);
v.pop_back(); v.pop_back();
}
else v.emplace_back(get<1>(lst[i]),get<2>(lst[i]));
}
if (!v.empty()) printf("-1");
else {
for (int i = 0; i < N; ++i) printf("%d %d\n", ans[i].first, ans[i].second);
}
return 0;
}
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... |