# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
403409 |
2021-05-13T06:57:12 Z |
zaneyu |
None (KOI16_laser) |
C++14 |
|
1 ms |
332 KB |
/*input
2
0 0
1 1
2 4
3 9
-1 1
-2 4
*/
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define f first
#define s second
#define sz(x) (int)x.size()
const int maxn=2e3+5;
pii ans[maxn];
int main(){
ios::sync_with_stdio(false),cin.tie(0);
int n;
cin>>n;
vector<pii> v;
priority_queue<pii> less,more;
vector<pii> vv;
REP(i,n){
int x,y;
cin>>x>>y;
v.pb({x,i});
}
REP1(i,2*n){
int x,y;
cin>>x>>y;
vv.pb({x,i});
}
sort(ALL(v));
sort(ALL(vv));
int p=0;
for(auto &x:v){
while(p<sz(vv) and vv[p].f<=x.f){
less.push(vv[p]);
++p;
}
if(!sz(less)){
continue;
}
else{
ans[x.s].f=less.top().s;
less.pop();
}
if(!sz(less)){
continue;
}
else{
ans[x.s].s=less.top().s;
less.pop();
}
}
vv.erase(vv.begin(),vv.begin()+p);
while(sz(less)) vv.pb(less.top()),less.pop();
sort(ALL(vv));
reverse(ALL(vv));
p=0;
for(auto x:v){
while(p<sz(vv) and vv[p].f>=x.f){
more.push(vv[p]);
++p;
}
if(!ans[x.s].f){
ans[x.s].f=more.top().s;
more.pop();
}
if(!ans[x.s].s){
ans[x.s].s=more.top().s;
more.pop();
}
}
REP(i,n) cout<<ans[i].f<<' '<<ans[i].s<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
320 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |