이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int n, k, q;
int blz[300005];
int a[300005], b[300005], t[300005], x[300005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>k>>q;
for(int i=0; i<n; i++)
{
cin>>x[i]>>t[i]>>a[i]>>b[i];
}
for(int i=0; i<q; i++)
{
int pos, vr;
cin>>pos>>vr;
for(int j=1; j<=k; j++) blz[j]=1e9;
for(int j=0; j<n; j++)
{
if(a[j]>vr || b[j]<vr) continue;
int st=x[j]-pos;
if(st<0) st=-st;
if(blz[t[j]]>st) blz[t[j]]=st;
}
int mx=0;
for(int j=1; j<=k; j++) mx=max(mx, blz[j]);
if(mx==1e9) cout<<-1<<endl;
else cout<<mx<<endl;
}
return 0;
}
/**
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
*/
| # | 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... |