This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define terminator main
#define N 60000
#define K 401
int t[N];
int x[N];
int l[N];
int ans[N];
set<int> s;
multiset<int> c[K];
map<int,vector<int>> a;
map<int,vector<int>> b;
map<int,vector<int>> Q;
void solve(){
int n,m,k,p,q,r;
cin>>n>>k>>m;
for(int i=1;i<=k;i++){
c[i].add(-1e9);
c[i].add(1e9);
}
for(int i=0;i<n;i++){
cin>>x[i]>>t[i]>>p>>q;
a[p].append(i);
b[q].append(i);
s.add(p);
s.add(q);
}
for(int i=0;i<m;i++){
cin>>l[i]>>p;
Q[p].append(i);
s.add(p);
}
for(auto& i:s){
for(auto& j:a[i])
c[t[j]].add(x[j]);
for(auto& j:Q[i]){
r=-1;
for(int z=1;z<=k;z++){
p=*(--c[z].lower_bound(l[j]));
q=*c[z].lower_bound(l[j]);
p=min(l[j]-p,q-l[j]);
r=max(p,r);
}
if(r>1e8) r=-1;
ans[j]=r;
}
for(auto& j:b[i])
c[t[j]].erase(c[t[j]].find(x[j]));
}
for(int i=0;i<m;i++)
cout<<ans[i]<<nl;
}
int terminator(){
L0TA;
solve();
return 0;
}
# | 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... |