Submission #203718

# Submission time Handle Problem Language Result Execution time Memory
203718 2020-02-22T01:03:23 Z Segtree New Home (APIO18_new_home) C++14
12 / 100
2393 ms 100936 KB
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define N 60010
ll n,q,k;
ll fans[N];
multiset<ll> s[410];
struct st{
	ll tim,x,col,typ;
	bool operator<(const st&key)const{
		if(this->tim==key.tim)return this->typ<key.typ;
		return this->tim<key.tim;
	}
};
int main(){
	cin>>n>>k>>q;
	vector<st> v;
	rep(i,n){
		ll x,col,a,b; cin>>x>>col>>a>>b; col--;
		v.push_back((struct st){a,x,col,0});
		v.push_back((struct st){b,x,col,2});
	}
	rep(i,q){
		ll l,y; cin>>l>>y;
		v.push_back((struct st){y,l,i,1});
	}
	sort(v.begin(),v.end());
	rep(i,k){
		s[i].insert(-1);
		s[i].insert(2e8);
	}
	for(auto e:v){
		if(e.typ==0){
			s[e.col].insert(e.x);
		}
		if(e.typ==1){
			ll ans=0;
			rep(i,k){
				ll mi=1e17;
				auto it=s[i].lower_bound(e.x);
				if(*it<2e8)chmin(mi,*it-e.x);
				it--;
				if(*it>-1)chmin(mi,e.x-*it);
				chmax(ans,mi);
			}
			if(ans==1e17)ans=-1;
			fans[e.col]=ans;
		}
		if(e.typ==2){
			s[e.col].erase(s[e.col].find(e.x));
		}
	}
	rep(i,q)cout<<fans[i]<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 7 ms 504 KB Output is correct
7 Correct 9 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 8 ms 376 KB Output is correct
12 Correct 7 ms 504 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 8 ms 376 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 7 ms 376 KB Output is correct
18 Correct 8 ms 376 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 7 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 9 ms 504 KB Output is correct
23 Correct 8 ms 380 KB Output is correct
24 Correct 8 ms 376 KB Output is correct
25 Correct 7 ms 504 KB Output is correct
26 Correct 7 ms 376 KB Output is correct
27 Correct 7 ms 376 KB Output is correct
28 Correct 7 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 7 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 7 ms 504 KB Output is correct
7 Correct 9 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 8 ms 376 KB Output is correct
12 Correct 7 ms 504 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 8 ms 376 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 7 ms 376 KB Output is correct
18 Correct 8 ms 376 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 7 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 9 ms 504 KB Output is correct
23 Correct 8 ms 380 KB Output is correct
24 Correct 8 ms 376 KB Output is correct
25 Correct 7 ms 504 KB Output is correct
26 Correct 7 ms 376 KB Output is correct
27 Correct 7 ms 376 KB Output is correct
28 Correct 7 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 7 ms 376 KB Output is correct
31 Correct 2393 ms 12780 KB Output is correct
32 Correct 273 ms 9564 KB Output is correct
33 Correct 449 ms 10844 KB Output is correct
34 Correct 1966 ms 11088 KB Output is correct
35 Correct 1215 ms 12752 KB Output is correct
36 Correct 474 ms 12496 KB Output is correct
37 Correct 434 ms 10844 KB Output is correct
38 Correct 381 ms 10848 KB Output is correct
39 Correct 365 ms 10844 KB Output is correct
40 Correct 368 ms 11036 KB Output is correct
41 Correct 639 ms 11112 KB Output is correct
42 Correct 759 ms 11100 KB Output is correct
43 Correct 568 ms 12372 KB Output is correct
44 Correct 578 ms 10844 KB Output is correct
45 Correct 416 ms 10844 KB Output is correct
46 Correct 351 ms 11040 KB Output is correct
47 Correct 341 ms 10844 KB Output is correct
48 Correct 339 ms 10844 KB Output is correct
49 Correct 370 ms 10844 KB Output is correct
50 Correct 550 ms 10844 KB Output is correct
51 Correct 351 ms 10844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1043 ms 74272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1176 ms 100936 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 7 ms 504 KB Output is correct
7 Correct 9 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 8 ms 376 KB Output is correct
12 Correct 7 ms 504 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 8 ms 376 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 7 ms 376 KB Output is correct
18 Correct 8 ms 376 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 7 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 9 ms 504 KB Output is correct
23 Correct 8 ms 380 KB Output is correct
24 Correct 8 ms 376 KB Output is correct
25 Correct 7 ms 504 KB Output is correct
26 Correct 7 ms 376 KB Output is correct
27 Correct 7 ms 376 KB Output is correct
28 Correct 7 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 7 ms 376 KB Output is correct
31 Correct 2393 ms 12780 KB Output is correct
32 Correct 273 ms 9564 KB Output is correct
33 Correct 449 ms 10844 KB Output is correct
34 Correct 1966 ms 11088 KB Output is correct
35 Correct 1215 ms 12752 KB Output is correct
36 Correct 474 ms 12496 KB Output is correct
37 Correct 434 ms 10844 KB Output is correct
38 Correct 381 ms 10848 KB Output is correct
39 Correct 365 ms 10844 KB Output is correct
40 Correct 368 ms 11036 KB Output is correct
41 Correct 639 ms 11112 KB Output is correct
42 Correct 759 ms 11100 KB Output is correct
43 Correct 568 ms 12372 KB Output is correct
44 Correct 578 ms 10844 KB Output is correct
45 Correct 416 ms 10844 KB Output is correct
46 Correct 351 ms 11040 KB Output is correct
47 Correct 341 ms 10844 KB Output is correct
48 Correct 339 ms 10844 KB Output is correct
49 Correct 370 ms 10844 KB Output is correct
50 Correct 550 ms 10844 KB Output is correct
51 Correct 351 ms 10844 KB Output is correct
52 Runtime error 240 ms 18000 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 7 ms 504 KB Output is correct
7 Correct 9 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 9 ms 376 KB Output is correct
10 Correct 7 ms 504 KB Output is correct
11 Correct 8 ms 376 KB Output is correct
12 Correct 7 ms 504 KB Output is correct
13 Correct 7 ms 376 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 8 ms 376 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 7 ms 376 KB Output is correct
18 Correct 8 ms 376 KB Output is correct
19 Correct 8 ms 504 KB Output is correct
20 Correct 7 ms 376 KB Output is correct
21 Correct 8 ms 376 KB Output is correct
22 Correct 9 ms 504 KB Output is correct
23 Correct 8 ms 380 KB Output is correct
24 Correct 8 ms 376 KB Output is correct
25 Correct 7 ms 504 KB Output is correct
26 Correct 7 ms 376 KB Output is correct
27 Correct 7 ms 376 KB Output is correct
28 Correct 7 ms 376 KB Output is correct
29 Correct 7 ms 376 KB Output is correct
30 Correct 7 ms 376 KB Output is correct
31 Correct 2393 ms 12780 KB Output is correct
32 Correct 273 ms 9564 KB Output is correct
33 Correct 449 ms 10844 KB Output is correct
34 Correct 1966 ms 11088 KB Output is correct
35 Correct 1215 ms 12752 KB Output is correct
36 Correct 474 ms 12496 KB Output is correct
37 Correct 434 ms 10844 KB Output is correct
38 Correct 381 ms 10848 KB Output is correct
39 Correct 365 ms 10844 KB Output is correct
40 Correct 368 ms 11036 KB Output is correct
41 Correct 639 ms 11112 KB Output is correct
42 Correct 759 ms 11100 KB Output is correct
43 Correct 568 ms 12372 KB Output is correct
44 Correct 578 ms 10844 KB Output is correct
45 Correct 416 ms 10844 KB Output is correct
46 Correct 351 ms 11040 KB Output is correct
47 Correct 341 ms 10844 KB Output is correct
48 Correct 339 ms 10844 KB Output is correct
49 Correct 370 ms 10844 KB Output is correct
50 Correct 550 ms 10844 KB Output is correct
51 Correct 351 ms 10844 KB Output is correct
52 Runtime error 1043 ms 74272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
53 Halted 0 ms 0 KB -