Submission #402250

#TimeUsernameProblemLanguageResultExecution timeMemory
402250A_DNew Home (APIO18_new_home)C++14
5 / 100
3 ms460 KiB
#include <bits/stdc++.h> #define int long long #define ii pair<int,int> #define F first #define S second #define du long double using namespace std; const int N=410; int x[N]; int a[N]; int b[N]; int t[N]; void solve() { int n,k,q; cin>>n>>k>>q; for(int i=1;i<=n;i++){ cin>>x[i]; cin>>t[i]; cin>>a[i]; cin>>b[i]; t[i]--; } while(q--){ int l,y; scanf("%lld",&l); scanf("%lld",&y); vector<int> vec(k,1e8+1); for(int i=1;i<=n;i++){ if(a[i]<=y&&y<=b[i]){ vec[t[i]]=min(vec[t[i]],abs(x[i]-l)); } } int ans=0,bo=0; for(auto x:vec){ if(x==1e8+1)bo=1; ans=max(ans,x); } if(bo)ans=-1; cout<<ans<<endl; } } main() { int t=1; // cin>>t; while(t--)solve(); } /* 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 2 1 3 1 1 1 4 1 1 2 6 1 3 1 5 1 7 1 1 1 100000000 1 1 1 1 1 */

Compilation message (stderr)

new_home.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
new_home.cpp: In function 'void solve()':
new_home.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         scanf("%lld",&l);
      |         ~~~~~^~~~~~~~~~~
new_home.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%lld",&y);
      |         ~~~~~^~~~~~~~~~~
#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...