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>
using namespace std;
struct store
{
int location,type,startingyear,endingyear;
};
void solve()
{
int n,k,q;
cin>>n>>k>>q;
vector<vector<int>> tp;
for(int i=0;i<n;i++)
{
int a,b,c,d;
cin>>a>>b>>c>>d;
tp.push_back({a,b,c,d});
}
long long tn=n;
long long tq=q;
long long nn=2e8;
if((tn*tq)<=nn)
{
while(q--)
{
int l,y;
cin>>l>>y;
set<int> typ,ind;
for(int i=0;i<n;i++)
{
if(tp[i][2]<=y and y<=tp[i][3])
{
typ.insert(tp[i][1]);
ind.insert(i);
}
}
if(typ.size()!=k)
{
cout<<-1<<endl;
}
else
{
map<int,int> tpp;
for(auto j:ind)
{
if(tpp.find(tp[j][1])==tpp.end())
{
tpp[tp[j][1]]=abs(l-tp[j][0]);
}
else
tpp[tp[j][1]]=min(tpp[tp[j][1]],abs(l-tp[j][0]));
}
int ans=0;
for(auto i:tpp)
ans=max(ans,i.second);
cout<<ans<<endl;
}
}
}
else
{
}
}
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(0);
solve();
return 0;
}
Compilation message (stderr)
new_home.cpp: In function 'void solve()':
new_home.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if(typ.size()!=k)
| ~~~~~~~~~~^~~
# | 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... |