# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
49357 |
2018-05-27T12:53:49 Z |
노영훈(#1273, Diuven) |
New Home (APIO18_new_home) |
C++ |
|
389 ms |
20792 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=300010, inf=2e9;
struct query{
int t, x, idx;
} Q[MX];
struct node {
int x, s, e;
};
vector<node> S[MX];
vector<int> T;
int n, q, k;
void init(){
cin>>n>>k>>q;
for(int i=1; i<=n; i++){
int x,p,s,e;
cin>>x>>p>>s>>e;
S[p].push_back({x,s,e});
T.push_back(s);
T.push_back(e);
}
for(int i=1; i<=q; i++){
int t,x;
cin>>x>>t;
Q[i]={t,x,i};
T.push_back(t);
}
sort(T.begin(), T.end());
T.resize(unique(T.begin(), T.end())-T.begin());
}
void solve1(){
for(int i=1; i<=q; i++){
int ans=0;
for(int p=1; p<=k; p++){
int now=inf;
for(node &nd:S[p]){
if(Q[i].t<nd.s || nd.e<Q[i].t) continue;
now=min(now, abs(Q[i].x-nd.x));
}
ans=max(ans, now);
}
if(ans==inf) ans=-1;
cout<<ans<<'\n';
}
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
init();
if(1LL*n*q<1e7){
solve1();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
7288 KB |
Output is correct |
2 |
Correct |
9 ms |
7396 KB |
Output is correct |
3 |
Correct |
9 ms |
7472 KB |
Output is correct |
4 |
Correct |
9 ms |
7548 KB |
Output is correct |
5 |
Correct |
10 ms |
7584 KB |
Output is correct |
6 |
Correct |
9 ms |
7584 KB |
Output is correct |
7 |
Correct |
10 ms |
7584 KB |
Output is correct |
8 |
Correct |
10 ms |
7584 KB |
Output is correct |
9 |
Correct |
10 ms |
7584 KB |
Output is correct |
10 |
Correct |
10 ms |
7584 KB |
Output is correct |
11 |
Correct |
9 ms |
7604 KB |
Output is correct |
12 |
Correct |
8 ms |
7604 KB |
Output is correct |
13 |
Correct |
9 ms |
7604 KB |
Output is correct |
14 |
Correct |
10 ms |
7604 KB |
Output is correct |
15 |
Correct |
8 ms |
7604 KB |
Output is correct |
16 |
Correct |
15 ms |
7604 KB |
Output is correct |
17 |
Correct |
8 ms |
7660 KB |
Output is correct |
18 |
Correct |
10 ms |
7660 KB |
Output is correct |
19 |
Correct |
11 ms |
7788 KB |
Output is correct |
20 |
Correct |
12 ms |
7788 KB |
Output is correct |
21 |
Correct |
9 ms |
7788 KB |
Output is correct |
22 |
Correct |
10 ms |
7788 KB |
Output is correct |
23 |
Correct |
12 ms |
7788 KB |
Output is correct |
24 |
Correct |
9 ms |
7788 KB |
Output is correct |
25 |
Correct |
9 ms |
7788 KB |
Output is correct |
26 |
Correct |
10 ms |
7788 KB |
Output is correct |
27 |
Correct |
9 ms |
7788 KB |
Output is correct |
28 |
Correct |
9 ms |
7788 KB |
Output is correct |
29 |
Correct |
9 ms |
7788 KB |
Output is correct |
30 |
Correct |
9 ms |
7788 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
7288 KB |
Output is correct |
2 |
Correct |
9 ms |
7396 KB |
Output is correct |
3 |
Correct |
9 ms |
7472 KB |
Output is correct |
4 |
Correct |
9 ms |
7548 KB |
Output is correct |
5 |
Correct |
10 ms |
7584 KB |
Output is correct |
6 |
Correct |
9 ms |
7584 KB |
Output is correct |
7 |
Correct |
10 ms |
7584 KB |
Output is correct |
8 |
Correct |
10 ms |
7584 KB |
Output is correct |
9 |
Correct |
10 ms |
7584 KB |
Output is correct |
10 |
Correct |
10 ms |
7584 KB |
Output is correct |
11 |
Correct |
9 ms |
7604 KB |
Output is correct |
12 |
Correct |
8 ms |
7604 KB |
Output is correct |
13 |
Correct |
9 ms |
7604 KB |
Output is correct |
14 |
Correct |
10 ms |
7604 KB |
Output is correct |
15 |
Correct |
8 ms |
7604 KB |
Output is correct |
16 |
Correct |
15 ms |
7604 KB |
Output is correct |
17 |
Correct |
8 ms |
7660 KB |
Output is correct |
18 |
Correct |
10 ms |
7660 KB |
Output is correct |
19 |
Correct |
11 ms |
7788 KB |
Output is correct |
20 |
Correct |
12 ms |
7788 KB |
Output is correct |
21 |
Correct |
9 ms |
7788 KB |
Output is correct |
22 |
Correct |
10 ms |
7788 KB |
Output is correct |
23 |
Correct |
12 ms |
7788 KB |
Output is correct |
24 |
Correct |
9 ms |
7788 KB |
Output is correct |
25 |
Correct |
9 ms |
7788 KB |
Output is correct |
26 |
Correct |
10 ms |
7788 KB |
Output is correct |
27 |
Correct |
9 ms |
7788 KB |
Output is correct |
28 |
Correct |
9 ms |
7788 KB |
Output is correct |
29 |
Correct |
9 ms |
7788 KB |
Output is correct |
30 |
Correct |
9 ms |
7788 KB |
Output is correct |
31 |
Incorrect |
76 ms |
10364 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
389 ms |
20792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
325 ms |
20792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
7288 KB |
Output is correct |
2 |
Correct |
9 ms |
7396 KB |
Output is correct |
3 |
Correct |
9 ms |
7472 KB |
Output is correct |
4 |
Correct |
9 ms |
7548 KB |
Output is correct |
5 |
Correct |
10 ms |
7584 KB |
Output is correct |
6 |
Correct |
9 ms |
7584 KB |
Output is correct |
7 |
Correct |
10 ms |
7584 KB |
Output is correct |
8 |
Correct |
10 ms |
7584 KB |
Output is correct |
9 |
Correct |
10 ms |
7584 KB |
Output is correct |
10 |
Correct |
10 ms |
7584 KB |
Output is correct |
11 |
Correct |
9 ms |
7604 KB |
Output is correct |
12 |
Correct |
8 ms |
7604 KB |
Output is correct |
13 |
Correct |
9 ms |
7604 KB |
Output is correct |
14 |
Correct |
10 ms |
7604 KB |
Output is correct |
15 |
Correct |
8 ms |
7604 KB |
Output is correct |
16 |
Correct |
15 ms |
7604 KB |
Output is correct |
17 |
Correct |
8 ms |
7660 KB |
Output is correct |
18 |
Correct |
10 ms |
7660 KB |
Output is correct |
19 |
Correct |
11 ms |
7788 KB |
Output is correct |
20 |
Correct |
12 ms |
7788 KB |
Output is correct |
21 |
Correct |
9 ms |
7788 KB |
Output is correct |
22 |
Correct |
10 ms |
7788 KB |
Output is correct |
23 |
Correct |
12 ms |
7788 KB |
Output is correct |
24 |
Correct |
9 ms |
7788 KB |
Output is correct |
25 |
Correct |
9 ms |
7788 KB |
Output is correct |
26 |
Correct |
10 ms |
7788 KB |
Output is correct |
27 |
Correct |
9 ms |
7788 KB |
Output is correct |
28 |
Correct |
9 ms |
7788 KB |
Output is correct |
29 |
Correct |
9 ms |
7788 KB |
Output is correct |
30 |
Correct |
9 ms |
7788 KB |
Output is correct |
31 |
Incorrect |
76 ms |
10364 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
7288 KB |
Output is correct |
2 |
Correct |
9 ms |
7396 KB |
Output is correct |
3 |
Correct |
9 ms |
7472 KB |
Output is correct |
4 |
Correct |
9 ms |
7548 KB |
Output is correct |
5 |
Correct |
10 ms |
7584 KB |
Output is correct |
6 |
Correct |
9 ms |
7584 KB |
Output is correct |
7 |
Correct |
10 ms |
7584 KB |
Output is correct |
8 |
Correct |
10 ms |
7584 KB |
Output is correct |
9 |
Correct |
10 ms |
7584 KB |
Output is correct |
10 |
Correct |
10 ms |
7584 KB |
Output is correct |
11 |
Correct |
9 ms |
7604 KB |
Output is correct |
12 |
Correct |
8 ms |
7604 KB |
Output is correct |
13 |
Correct |
9 ms |
7604 KB |
Output is correct |
14 |
Correct |
10 ms |
7604 KB |
Output is correct |
15 |
Correct |
8 ms |
7604 KB |
Output is correct |
16 |
Correct |
15 ms |
7604 KB |
Output is correct |
17 |
Correct |
8 ms |
7660 KB |
Output is correct |
18 |
Correct |
10 ms |
7660 KB |
Output is correct |
19 |
Correct |
11 ms |
7788 KB |
Output is correct |
20 |
Correct |
12 ms |
7788 KB |
Output is correct |
21 |
Correct |
9 ms |
7788 KB |
Output is correct |
22 |
Correct |
10 ms |
7788 KB |
Output is correct |
23 |
Correct |
12 ms |
7788 KB |
Output is correct |
24 |
Correct |
9 ms |
7788 KB |
Output is correct |
25 |
Correct |
9 ms |
7788 KB |
Output is correct |
26 |
Correct |
10 ms |
7788 KB |
Output is correct |
27 |
Correct |
9 ms |
7788 KB |
Output is correct |
28 |
Correct |
9 ms |
7788 KB |
Output is correct |
29 |
Correct |
9 ms |
7788 KB |
Output is correct |
30 |
Correct |
9 ms |
7788 KB |
Output is correct |
31 |
Incorrect |
76 ms |
10364 KB |
Output isn't correct |
32 |
Halted |
0 ms |
0 KB |
- |