#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int main()
{
ios::sync_with_stdio(0);
cin.tie(NULL), cout.tie(NULL);
int n,k,q;
cin>>n>>k>>q;
set<int> se;
map<int,int> com;
vector<vector<int>> ev,que;
int t,a,s,e;
for (int i=0;i<n;i++)
{
cin>>a>>t>>s>>e,t--;
ev.push_back({s,e,a,t});
se.insert(s),se.insert(e);
}
int ans[q]={};
while (q--)
{
int l,y;
cin>>l>>y;
se.insert(y);
que.push_back({y,l,(int)que.size()});
}
for (int i:se)
com[i]=com.size();
int m=com.size();
vector<pair<int,int>> st[m],en[m],qu[m];
for (auto i:ev)
{
st[com[i[0]]].push_back({i[2],i[3]});
en[com[i[1]]].push_back({i[2],i[3]});
}
for (auto i:que)
qu[com[i[0]]].push_back({i[1],i[2]});
multiset<int> ms[k];
for (int c=0;c<m;c++)
{
for (auto i:st[c])
ms[i.second].insert(i.first);
for (auto i:qu[c])
for (t=0;t<k;t++)
{
if (ms[t].empty())
{
ans[i.second]=-1;
break;
}
auto x=ms[t].lower_bound(i.first);
int val=inf;
if (x!=ms[t].end())
val=*x-i.first;
if (x!=ms[t].begin())
{
x--;
val=min(val,i.first-*x);
}
ans[i.second]=max(ans[i.second],val);
}
for (auto i:en[c])
ms[i.second].erase(ms[i.second].find(i.first));
}
for (int i:ans)
cout<<i<<' ';
cout<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
564 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
1 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
564 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
1 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1431 ms |
48660 KB |
Output is correct |
32 |
Correct |
61 ms |
11012 KB |
Output is correct |
33 |
Correct |
258 ms |
46592 KB |
Output is correct |
34 |
Correct |
1110 ms |
46752 KB |
Output is correct |
35 |
Correct |
737 ms |
48644 KB |
Output is correct |
36 |
Correct |
272 ms |
48384 KB |
Output is correct |
37 |
Correct |
222 ms |
45880 KB |
Output is correct |
38 |
Correct |
176 ms |
45828 KB |
Output is correct |
39 |
Correct |
147 ms |
45572 KB |
Output is correct |
40 |
Correct |
148 ms |
45660 KB |
Output is correct |
41 |
Correct |
268 ms |
45828 KB |
Output is correct |
42 |
Correct |
243 ms |
45568 KB |
Output is correct |
43 |
Correct |
139 ms |
14340 KB |
Output is correct |
44 |
Correct |
249 ms |
45936 KB |
Output is correct |
45 |
Correct |
197 ms |
45856 KB |
Output is correct |
46 |
Correct |
140 ms |
45832 KB |
Output is correct |
47 |
Correct |
123 ms |
44292 KB |
Output is correct |
48 |
Correct |
108 ms |
43780 KB |
Output is correct |
49 |
Correct |
149 ms |
44800 KB |
Output is correct |
50 |
Correct |
188 ms |
45316 KB |
Output is correct |
51 |
Correct |
125 ms |
44548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5046 ms |
118008 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5029 ms |
172392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
564 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
1 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1431 ms |
48660 KB |
Output is correct |
32 |
Correct |
61 ms |
11012 KB |
Output is correct |
33 |
Correct |
258 ms |
46592 KB |
Output is correct |
34 |
Correct |
1110 ms |
46752 KB |
Output is correct |
35 |
Correct |
737 ms |
48644 KB |
Output is correct |
36 |
Correct |
272 ms |
48384 KB |
Output is correct |
37 |
Correct |
222 ms |
45880 KB |
Output is correct |
38 |
Correct |
176 ms |
45828 KB |
Output is correct |
39 |
Correct |
147 ms |
45572 KB |
Output is correct |
40 |
Correct |
148 ms |
45660 KB |
Output is correct |
41 |
Correct |
268 ms |
45828 KB |
Output is correct |
42 |
Correct |
243 ms |
45568 KB |
Output is correct |
43 |
Correct |
139 ms |
14340 KB |
Output is correct |
44 |
Correct |
249 ms |
45936 KB |
Output is correct |
45 |
Correct |
197 ms |
45856 KB |
Output is correct |
46 |
Correct |
140 ms |
45832 KB |
Output is correct |
47 |
Correct |
123 ms |
44292 KB |
Output is correct |
48 |
Correct |
108 ms |
43780 KB |
Output is correct |
49 |
Correct |
149 ms |
44800 KB |
Output is correct |
50 |
Correct |
188 ms |
45316 KB |
Output is correct |
51 |
Correct |
125 ms |
44548 KB |
Output is correct |
52 |
Correct |
213 ms |
51200 KB |
Output is correct |
53 |
Correct |
204 ms |
49504 KB |
Output is correct |
54 |
Correct |
261 ms |
49404 KB |
Output is correct |
55 |
Execution timed out |
5053 ms |
47104 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
564 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
1 ms |
604 KB |
Output is correct |
18 |
Correct |
1 ms |
604 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
1 ms |
604 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
24 |
Correct |
1 ms |
604 KB |
Output is correct |
25 |
Correct |
1 ms |
604 KB |
Output is correct |
26 |
Correct |
1 ms |
604 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
604 KB |
Output is correct |
29 |
Correct |
1 ms |
604 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
1431 ms |
48660 KB |
Output is correct |
32 |
Correct |
61 ms |
11012 KB |
Output is correct |
33 |
Correct |
258 ms |
46592 KB |
Output is correct |
34 |
Correct |
1110 ms |
46752 KB |
Output is correct |
35 |
Correct |
737 ms |
48644 KB |
Output is correct |
36 |
Correct |
272 ms |
48384 KB |
Output is correct |
37 |
Correct |
222 ms |
45880 KB |
Output is correct |
38 |
Correct |
176 ms |
45828 KB |
Output is correct |
39 |
Correct |
147 ms |
45572 KB |
Output is correct |
40 |
Correct |
148 ms |
45660 KB |
Output is correct |
41 |
Correct |
268 ms |
45828 KB |
Output is correct |
42 |
Correct |
243 ms |
45568 KB |
Output is correct |
43 |
Correct |
139 ms |
14340 KB |
Output is correct |
44 |
Correct |
249 ms |
45936 KB |
Output is correct |
45 |
Correct |
197 ms |
45856 KB |
Output is correct |
46 |
Correct |
140 ms |
45832 KB |
Output is correct |
47 |
Correct |
123 ms |
44292 KB |
Output is correct |
48 |
Correct |
108 ms |
43780 KB |
Output is correct |
49 |
Correct |
149 ms |
44800 KB |
Output is correct |
50 |
Correct |
188 ms |
45316 KB |
Output is correct |
51 |
Correct |
125 ms |
44548 KB |
Output is correct |
52 |
Execution timed out |
5046 ms |
118008 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |