이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
const char nl = '\n';
void fastIO() {
ios::sync_with_stdio(false);
cin.tie(0);
}
int main() {
fastIO();
int N, K, Q;
cin>>N>>K>>Q;
// stores of each type
vector<pair<int, ii>> stores[K];
// {pos, {start, end}}
for (int i = 0; i < N; i++) {
int x, y, a, b;
cin>>x>>y>>a>>b;
x--; y--;
stores[y].pb({x, {a, b}});
}
for (int i = 0; i < Q; i++) {
int x, t;
cin>>x>>t;
x--;
vi nd(K, 1e9);
for (int j = 0; j < K; j++) {
for (pair<int, ii> p : stores[j]) {
if (p.se.fi <= t && t <= p.se.se)
nd[j] = min(nd[j], abs(p.fi - x));
}
}
int ans = -1;
for (int x : nd)
ans = max(ans, x);
// cout<<"ANSWER: ";
if (ans != 1e9)
cout<<ans<<endl;
else
cout<<-1<<endl;
}
}
| # | 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... |