#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;
unordered_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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 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 |
600 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 |
2 ms |
600 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 |
600 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
2 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
720 KB |
Output is correct |
18 |
Correct |
1 ms |
776 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 |
728 KB |
Output is correct |
23 |
Correct |
1 ms |
724 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
1 ms |
608 KB |
Output is correct |
26 |
Correct |
1 ms |
724 KB |
Output is correct |
27 |
Correct |
1 ms |
344 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 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 |
600 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 |
2 ms |
600 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 |
600 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
2 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
720 KB |
Output is correct |
18 |
Correct |
1 ms |
776 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 |
728 KB |
Output is correct |
23 |
Correct |
1 ms |
724 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
1 ms |
608 KB |
Output is correct |
26 |
Correct |
1 ms |
724 KB |
Output is correct |
27 |
Correct |
1 ms |
344 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 |
1621 ms |
47276 KB |
Output is correct |
32 |
Correct |
83 ms |
10808 KB |
Output is correct |
33 |
Correct |
275 ms |
45468 KB |
Output is correct |
34 |
Correct |
1143 ms |
45496 KB |
Output is correct |
35 |
Correct |
764 ms |
47284 KB |
Output is correct |
36 |
Correct |
272 ms |
47284 KB |
Output is correct |
37 |
Correct |
252 ms |
44572 KB |
Output is correct |
38 |
Correct |
195 ms |
44724 KB |
Output is correct |
39 |
Correct |
145 ms |
44468 KB |
Output is correct |
40 |
Correct |
168 ms |
44372 KB |
Output is correct |
41 |
Correct |
271 ms |
44468 KB |
Output is correct |
42 |
Correct |
226 ms |
44472 KB |
Output is correct |
43 |
Correct |
135 ms |
13432 KB |
Output is correct |
44 |
Correct |
246 ms |
44728 KB |
Output is correct |
45 |
Correct |
164 ms |
44728 KB |
Output is correct |
46 |
Correct |
139 ms |
44528 KB |
Output is correct |
47 |
Correct |
130 ms |
43088 KB |
Output is correct |
48 |
Correct |
129 ms |
42676 KB |
Output is correct |
49 |
Correct |
125 ms |
43456 KB |
Output is correct |
50 |
Correct |
194 ms |
44080 KB |
Output is correct |
51 |
Correct |
118 ms |
43316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5061 ms |
112808 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5045 ms |
164568 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 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 |
600 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 |
2 ms |
600 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 |
600 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
2 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
720 KB |
Output is correct |
18 |
Correct |
1 ms |
776 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 |
728 KB |
Output is correct |
23 |
Correct |
1 ms |
724 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
1 ms |
608 KB |
Output is correct |
26 |
Correct |
1 ms |
724 KB |
Output is correct |
27 |
Correct |
1 ms |
344 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 |
1621 ms |
47276 KB |
Output is correct |
32 |
Correct |
83 ms |
10808 KB |
Output is correct |
33 |
Correct |
275 ms |
45468 KB |
Output is correct |
34 |
Correct |
1143 ms |
45496 KB |
Output is correct |
35 |
Correct |
764 ms |
47284 KB |
Output is correct |
36 |
Correct |
272 ms |
47284 KB |
Output is correct |
37 |
Correct |
252 ms |
44572 KB |
Output is correct |
38 |
Correct |
195 ms |
44724 KB |
Output is correct |
39 |
Correct |
145 ms |
44468 KB |
Output is correct |
40 |
Correct |
168 ms |
44372 KB |
Output is correct |
41 |
Correct |
271 ms |
44468 KB |
Output is correct |
42 |
Correct |
226 ms |
44472 KB |
Output is correct |
43 |
Correct |
135 ms |
13432 KB |
Output is correct |
44 |
Correct |
246 ms |
44728 KB |
Output is correct |
45 |
Correct |
164 ms |
44728 KB |
Output is correct |
46 |
Correct |
139 ms |
44528 KB |
Output is correct |
47 |
Correct |
130 ms |
43088 KB |
Output is correct |
48 |
Correct |
129 ms |
42676 KB |
Output is correct |
49 |
Correct |
125 ms |
43456 KB |
Output is correct |
50 |
Correct |
194 ms |
44080 KB |
Output is correct |
51 |
Correct |
118 ms |
43316 KB |
Output is correct |
52 |
Correct |
160 ms |
49856 KB |
Output is correct |
53 |
Correct |
176 ms |
48180 KB |
Output is correct |
54 |
Correct |
207 ms |
48056 KB |
Output is correct |
55 |
Execution timed out |
5050 ms |
45904 KB |
Time limit exceeded |
56 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 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 |
600 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 |
2 ms |
600 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 |
600 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
600 KB |
Output is correct |
16 |
Correct |
2 ms |
600 KB |
Output is correct |
17 |
Correct |
1 ms |
720 KB |
Output is correct |
18 |
Correct |
1 ms |
776 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 |
728 KB |
Output is correct |
23 |
Correct |
1 ms |
724 KB |
Output is correct |
24 |
Correct |
1 ms |
600 KB |
Output is correct |
25 |
Correct |
1 ms |
608 KB |
Output is correct |
26 |
Correct |
1 ms |
724 KB |
Output is correct |
27 |
Correct |
1 ms |
344 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 |
1621 ms |
47276 KB |
Output is correct |
32 |
Correct |
83 ms |
10808 KB |
Output is correct |
33 |
Correct |
275 ms |
45468 KB |
Output is correct |
34 |
Correct |
1143 ms |
45496 KB |
Output is correct |
35 |
Correct |
764 ms |
47284 KB |
Output is correct |
36 |
Correct |
272 ms |
47284 KB |
Output is correct |
37 |
Correct |
252 ms |
44572 KB |
Output is correct |
38 |
Correct |
195 ms |
44724 KB |
Output is correct |
39 |
Correct |
145 ms |
44468 KB |
Output is correct |
40 |
Correct |
168 ms |
44372 KB |
Output is correct |
41 |
Correct |
271 ms |
44468 KB |
Output is correct |
42 |
Correct |
226 ms |
44472 KB |
Output is correct |
43 |
Correct |
135 ms |
13432 KB |
Output is correct |
44 |
Correct |
246 ms |
44728 KB |
Output is correct |
45 |
Correct |
164 ms |
44728 KB |
Output is correct |
46 |
Correct |
139 ms |
44528 KB |
Output is correct |
47 |
Correct |
130 ms |
43088 KB |
Output is correct |
48 |
Correct |
129 ms |
42676 KB |
Output is correct |
49 |
Correct |
125 ms |
43456 KB |
Output is correct |
50 |
Correct |
194 ms |
44080 KB |
Output is correct |
51 |
Correct |
118 ms |
43316 KB |
Output is correct |
52 |
Execution timed out |
5061 ms |
112808 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |