# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403584 | tqbfjotld | 레이저 센서 (KOI16_laser) | C++14 | 1 ms | 204 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;
vector<pair<int,pair<int,int> > > points;
vector<int> ans[1005];
int main(){
int n;
scanf("%d",&n);
for (int x = 0;x<n; x++){
int a,b;
scanf("%d%d",&a,&b);
points.push_back({a,{x,0}});
}
for (int x = 0; x<2*n; x++){
int a,b;
scanf("%d%d",&a,&b);
points.push_back({a,{x,1}});
}
sort(points.begin(),points.end());
vector<pair<int,int> > red;
vector<pair<int,int> > b;
for (auto x : points){
if (x.second.second){
if (!b.empty()){
ans[b.back().second].push_back(x.second.first);
b.pop_back();
}
else{
red.push_back({x.first,x.second.first});
}
}
else{
for (int k = 0; k<2; k++){
if (!red.empty()){
ans[x.second.first].push_back(red.back().second);
red.pop_back();
}
else{
b.push_back({x.first,x.second.first});
}
}
}
}
for (int x = 0; x<n; x++){
printf("%d %d\n",ans[x][0],ans[x][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... |