Submission #738510

# Submission time Handle Problem Language Result Execution time Memory
738510 2023-05-09T01:09:12 Z 089487 New Home (APIO18_new_home) C++14
5 / 100
5000 ms 1048576 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,popcnt,sse4,abm")
#include<bits/stdc++.h>
#define int long long
#define quick ios::sync_with_stdio(0);cin.tie(0);
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define repd(x,a,b) for(int x=a;x>=b;x--)
#define lowbit(x) (x&-x)
#define sz(x) (int)(x.size())
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mp make_pair
#define eb emplace_back
using namespace std;
typedef pair<int,int> pii;
void debug(){
    cout<<"\n";
}
template <class T,class ... U >
void debug(T a, U ... b){
    cout<<a<<" ",debug(b...);
}
const int N=8e6+7;
const int INF=1e18;
set<int> st[N];
int L[N];
int R[N];
int root[N];
int cnt=0;
void Update(int &now,int val,int l,int r,int lx=0,int rx=1e8+7){
	if(!now) now=++cnt;
	if(l<=lx&&rx<=r){
		st[now].insert(val);
		return ;
	}
	if(l>=rx||lx>=r) return ;
	int mid=(lx+rx)>>1;
	Update(L[now],val,l,r,lx,mid);
	Update(R[now],val,l,r,mid,rx);
}
int qry(int now,int pos,int val,int lx=0,int rx=1e8+7){
	if(!now) return INF;
	int ret=INF;
	auto it=st[now].lower_bound(val);
	if(it!=st[now].end()) ret=min(ret,*it-val);
	if(it!=st[now].begin()) ret=min(ret,val-*prev(it));
	if(lx==rx-1) return ret;
	int mid=(lx+rx)>>1;
	if(pos<mid) return min(ret,qry(L[now],pos,val,lx,mid));
	return min(ret,qry(R[now],pos,val,mid,rx));
}
int x[N];
int t[N];
int a[N];
int b[N];
signed main(){
	quick
	int n,k,q;
	cin>>n>>k>>q;
	rep(i,1,n){
		cin>>x[i]>>t[i]>>a[i]>>b[i];
		Update(root[t[i]],x[i],a[i],b[i]+1);
	}
	while(q--){
		int l,y;
		cin>>l>>y;
		int ret=-1;
		rep(type,1,k){
			ret=max(ret,qry(root[type],y,l));
		}
		cout<<(ret>=INF ? -1 : ret)<<"\n";
	}

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 171 ms 376160 KB Output is correct
2 Correct 178 ms 376088 KB Output is correct
3 Correct 172 ms 375972 KB Output is correct
4 Correct 176 ms 376100 KB Output is correct
5 Correct 173 ms 376096 KB Output is correct
6 Correct 175 ms 377004 KB Output is correct
7 Correct 179 ms 377084 KB Output is correct
8 Correct 180 ms 377148 KB Output is correct
9 Correct 184 ms 377312 KB Output is correct
10 Correct 174 ms 377096 KB Output is correct
11 Correct 175 ms 376976 KB Output is correct
12 Correct 178 ms 376972 KB Output is correct
13 Correct 180 ms 376812 KB Output is correct
14 Correct 173 ms 376888 KB Output is correct
15 Correct 175 ms 377036 KB Output is correct
16 Correct 188 ms 377100 KB Output is correct
17 Correct 177 ms 377084 KB Output is correct
18 Correct 182 ms 377076 KB Output is correct
19 Correct 190 ms 377224 KB Output is correct
20 Correct 179 ms 377060 KB Output is correct
21 Correct 194 ms 377532 KB Output is correct
22 Correct 184 ms 377252 KB Output is correct
23 Correct 179 ms 377164 KB Output is correct
24 Correct 181 ms 377140 KB Output is correct
25 Correct 180 ms 377120 KB Output is correct
26 Correct 179 ms 377040 KB Output is correct
27 Correct 178 ms 376140 KB Output is correct
28 Correct 173 ms 376944 KB Output is correct
29 Correct 176 ms 377036 KB Output is correct
30 Correct 183 ms 376680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 171 ms 376160 KB Output is correct
2 Correct 178 ms 376088 KB Output is correct
3 Correct 172 ms 375972 KB Output is correct
4 Correct 176 ms 376100 KB Output is correct
5 Correct 173 ms 376096 KB Output is correct
6 Correct 175 ms 377004 KB Output is correct
7 Correct 179 ms 377084 KB Output is correct
8 Correct 180 ms 377148 KB Output is correct
9 Correct 184 ms 377312 KB Output is correct
10 Correct 174 ms 377096 KB Output is correct
11 Correct 175 ms 376976 KB Output is correct
12 Correct 178 ms 376972 KB Output is correct
13 Correct 180 ms 376812 KB Output is correct
14 Correct 173 ms 376888 KB Output is correct
15 Correct 175 ms 377036 KB Output is correct
16 Correct 188 ms 377100 KB Output is correct
17 Correct 177 ms 377084 KB Output is correct
18 Correct 182 ms 377076 KB Output is correct
19 Correct 190 ms 377224 KB Output is correct
20 Correct 179 ms 377060 KB Output is correct
21 Correct 194 ms 377532 KB Output is correct
22 Correct 184 ms 377252 KB Output is correct
23 Correct 179 ms 377164 KB Output is correct
24 Correct 181 ms 377140 KB Output is correct
25 Correct 180 ms 377120 KB Output is correct
26 Correct 179 ms 377040 KB Output is correct
27 Correct 178 ms 376140 KB Output is correct
28 Correct 173 ms 376944 KB Output is correct
29 Correct 176 ms 377036 KB Output is correct
30 Correct 183 ms 376680 KB Output is correct
31 Execution timed out 5066 ms 518580 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1410 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1466 ms 1043664 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 171 ms 376160 KB Output is correct
2 Correct 178 ms 376088 KB Output is correct
3 Correct 172 ms 375972 KB Output is correct
4 Correct 176 ms 376100 KB Output is correct
5 Correct 173 ms 376096 KB Output is correct
6 Correct 175 ms 377004 KB Output is correct
7 Correct 179 ms 377084 KB Output is correct
8 Correct 180 ms 377148 KB Output is correct
9 Correct 184 ms 377312 KB Output is correct
10 Correct 174 ms 377096 KB Output is correct
11 Correct 175 ms 376976 KB Output is correct
12 Correct 178 ms 376972 KB Output is correct
13 Correct 180 ms 376812 KB Output is correct
14 Correct 173 ms 376888 KB Output is correct
15 Correct 175 ms 377036 KB Output is correct
16 Correct 188 ms 377100 KB Output is correct
17 Correct 177 ms 377084 KB Output is correct
18 Correct 182 ms 377076 KB Output is correct
19 Correct 190 ms 377224 KB Output is correct
20 Correct 179 ms 377060 KB Output is correct
21 Correct 194 ms 377532 KB Output is correct
22 Correct 184 ms 377252 KB Output is correct
23 Correct 179 ms 377164 KB Output is correct
24 Correct 181 ms 377140 KB Output is correct
25 Correct 180 ms 377120 KB Output is correct
26 Correct 179 ms 377040 KB Output is correct
27 Correct 178 ms 376140 KB Output is correct
28 Correct 173 ms 376944 KB Output is correct
29 Correct 176 ms 377036 KB Output is correct
30 Correct 183 ms 376680 KB Output is correct
31 Execution timed out 5066 ms 518580 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 171 ms 376160 KB Output is correct
2 Correct 178 ms 376088 KB Output is correct
3 Correct 172 ms 375972 KB Output is correct
4 Correct 176 ms 376100 KB Output is correct
5 Correct 173 ms 376096 KB Output is correct
6 Correct 175 ms 377004 KB Output is correct
7 Correct 179 ms 377084 KB Output is correct
8 Correct 180 ms 377148 KB Output is correct
9 Correct 184 ms 377312 KB Output is correct
10 Correct 174 ms 377096 KB Output is correct
11 Correct 175 ms 376976 KB Output is correct
12 Correct 178 ms 376972 KB Output is correct
13 Correct 180 ms 376812 KB Output is correct
14 Correct 173 ms 376888 KB Output is correct
15 Correct 175 ms 377036 KB Output is correct
16 Correct 188 ms 377100 KB Output is correct
17 Correct 177 ms 377084 KB Output is correct
18 Correct 182 ms 377076 KB Output is correct
19 Correct 190 ms 377224 KB Output is correct
20 Correct 179 ms 377060 KB Output is correct
21 Correct 194 ms 377532 KB Output is correct
22 Correct 184 ms 377252 KB Output is correct
23 Correct 179 ms 377164 KB Output is correct
24 Correct 181 ms 377140 KB Output is correct
25 Correct 180 ms 377120 KB Output is correct
26 Correct 179 ms 377040 KB Output is correct
27 Correct 178 ms 376140 KB Output is correct
28 Correct 173 ms 376944 KB Output is correct
29 Correct 176 ms 377036 KB Output is correct
30 Correct 183 ms 376680 KB Output is correct
31 Execution timed out 5066 ms 518580 KB Time limit exceeded
32 Halted 0 ms 0 KB -