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>
#define ALL(x) x.begin(),x.end()
struct Store
{
long pos;
long type;
long oYear;
long cYear;
};
int main()
{
long numStores, numTypes, numQ;
std::cin >> numStores;
std::cin >> numTypes;
std::cin >> numQ;
std::vector<Store> stores(numStores);
for (long s = 0; s < numStores; s++)
{
std::cin >> stores[s].pos;
std::cin >> stores[s].type;
std::cin >> stores[s].oYear;
std::cin >> stores[s].cYear;
stores[s].type--;
}
std::vector<long> minDist(numTypes);
for (long i = 0; i < numQ; i++)
{
long pos, year;
std::cin >> pos;
std::cin >> year;
std::fill(ALL(minDist), -1);
for (long s = 0; s < numStores; s++)
{
if (stores[s].cYear < year || stores[s].oYear > year)
continue;
long dist = std::abs(stores[s].pos - pos);
long& curDist = minDist[stores[s].type];
if (curDist == -1 || dist < curDist)
curDist = dist;
}
long inconv = -1;
for (long d : minDist)
{
if (d == -1)
{
inconv = -1;
break;
}
inconv = std::max(inconv, d);
}
std::cout << inconv << std::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... |