Submission #982337

#TimeUsernameProblemLanguageResultExecution timeMemory
982337Faisal_SaqibNew Home (APIO18_new_home)C++17
5 / 100
5055 ms42324 KiB
#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; 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<<'\n'; } } } 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:34:16: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |   if(typ.size()!=k)
      |      ~~~~~~~~~~^~~
new_home.cpp:18:12: warning: unused variable 'tn' [-Wunused-variable]
   18 |  long long tn=n;
      |            ^~
new_home.cpp:19:12: warning: unused variable 'tq' [-Wunused-variable]
   19 |  long long tq=q;
      |            ^~
new_home.cpp:20:12: warning: unused variable 'nn' [-Wunused-variable]
   20 |  long long nn=2e8;
      |            ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...