# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
53197 |
2018-06-29T01:16:21 Z |
ainta |
None (JOI16_matryoshka) |
C++17 |
|
455 ms |
91016 KB |
#include<cstdio>
#include<algorithm>
using namespace std;
#define SZ 262144
int n, QC, IT[SZ+SZ], Res[201000];
struct point {
int x, y, num;
bool operator<(const point &p)const {
return x != p.x ? x > p.x:y < p.y;
}
}w[201000], Q[201000];
int X[201000], Y[201000];
int Max(int b, int e) {
b += SZ, e += SZ;
int r = 0;
while (b <= e) {
r = max(r, max(IT[b], IT[e]));
b = (b + 1) >> 1, e = (e - 1) >> 1;
}
return r;
}
void Ins(int a, int b) {
a += SZ;
while (a) {
IT[a] = max(IT[a], b);
a >>= 1;
}
}
int main() {
int i, x, y;
scanf("%d%d", &n, &QC);
for (i = 1; i <= n; i++) {
scanf("%d%d", &X[i],&Y[i]);
w[i] = { X[i],Y[i],i };
}
sort(X + 1, X + n + 1);
sort(Y + 1, Y + n + 1);
for (i = 1; i <= QC; i++) {
scanf("%d%d", &x, &y);
x = lower_bound(X + 1, X + n + 1, x) - X;
y = lower_bound(Y + 1, Y + n + 1, y + 1) - Y - 1;
Q[i] = { x,y,i };
}
for (i = 1; i <= n; i++) {
w[i].x = lower_bound(X + 1, X + n + 1, w[i].x) - X;
w[i].y = lower_bound(Y + 1, Y + n + 1, w[i].y) - Y;
}
sort(w + 1, w + n + 1);
sort(Q + 1, Q + QC + 1);
int pv = 1;
for (i = 1; i <= QC; i++) {
while (pv<=n && w[pv].x >= Q[i].x) {
Ins(w[pv].y, Max(1, w[pv].y) + 1);
pv++;
}
Res[Q[i].num] = Max(1, Q[i].y);
}
for (i = 1; i <= QC; i++)printf("%d\n", Res[i]);
}
Compilation message
matryoshka.cpp: In function 'int main()':
matryoshka.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &QC);
~~~~~^~~~~~~~~~~~~~~~~
matryoshka.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &X[i],&Y[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~
matryoshka.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &x, &y);
~~~~~^~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
420 KB |
Output is correct |
5 |
Correct |
2 ms |
424 KB |
Output is correct |
6 |
Correct |
3 ms |
432 KB |
Output is correct |
7 |
Correct |
2 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
420 KB |
Output is correct |
5 |
Correct |
2 ms |
424 KB |
Output is correct |
6 |
Correct |
3 ms |
432 KB |
Output is correct |
7 |
Correct |
2 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
3 ms |
736 KB |
Output is correct |
12 |
Correct |
2 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
764 KB |
Output is correct |
15 |
Correct |
2 ms |
772 KB |
Output is correct |
16 |
Correct |
2 ms |
792 KB |
Output is correct |
17 |
Correct |
2 ms |
792 KB |
Output is correct |
18 |
Correct |
2 ms |
828 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
2 ms |
828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
420 KB |
Output is correct |
5 |
Correct |
2 ms |
424 KB |
Output is correct |
6 |
Correct |
3 ms |
432 KB |
Output is correct |
7 |
Correct |
2 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
3 ms |
736 KB |
Output is correct |
12 |
Correct |
2 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
764 KB |
Output is correct |
15 |
Correct |
2 ms |
772 KB |
Output is correct |
16 |
Correct |
2 ms |
792 KB |
Output is correct |
17 |
Correct |
2 ms |
792 KB |
Output is correct |
18 |
Correct |
2 ms |
828 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
2 ms |
828 KB |
Output is correct |
21 |
Correct |
2 ms |
828 KB |
Output is correct |
22 |
Correct |
4 ms |
828 KB |
Output is correct |
23 |
Correct |
5 ms |
976 KB |
Output is correct |
24 |
Correct |
5 ms |
1072 KB |
Output is correct |
25 |
Correct |
5 ms |
1152 KB |
Output is correct |
26 |
Correct |
5 ms |
1232 KB |
Output is correct |
27 |
Correct |
5 ms |
1316 KB |
Output is correct |
28 |
Correct |
5 ms |
1380 KB |
Output is correct |
29 |
Correct |
5 ms |
1460 KB |
Output is correct |
30 |
Correct |
5 ms |
1580 KB |
Output is correct |
31 |
Correct |
5 ms |
1580 KB |
Output is correct |
32 |
Correct |
5 ms |
1712 KB |
Output is correct |
33 |
Correct |
6 ms |
1720 KB |
Output is correct |
34 |
Correct |
5 ms |
1800 KB |
Output is correct |
35 |
Correct |
5 ms |
1928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
420 KB |
Output is correct |
5 |
Correct |
2 ms |
424 KB |
Output is correct |
6 |
Correct |
3 ms |
432 KB |
Output is correct |
7 |
Correct |
2 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
2 ms |
580 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
3 ms |
736 KB |
Output is correct |
12 |
Correct |
2 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
760 KB |
Output is correct |
14 |
Correct |
2 ms |
764 KB |
Output is correct |
15 |
Correct |
2 ms |
772 KB |
Output is correct |
16 |
Correct |
2 ms |
792 KB |
Output is correct |
17 |
Correct |
2 ms |
792 KB |
Output is correct |
18 |
Correct |
2 ms |
828 KB |
Output is correct |
19 |
Correct |
2 ms |
828 KB |
Output is correct |
20 |
Correct |
2 ms |
828 KB |
Output is correct |
21 |
Correct |
2 ms |
828 KB |
Output is correct |
22 |
Correct |
4 ms |
828 KB |
Output is correct |
23 |
Correct |
5 ms |
976 KB |
Output is correct |
24 |
Correct |
5 ms |
1072 KB |
Output is correct |
25 |
Correct |
5 ms |
1152 KB |
Output is correct |
26 |
Correct |
5 ms |
1232 KB |
Output is correct |
27 |
Correct |
5 ms |
1316 KB |
Output is correct |
28 |
Correct |
5 ms |
1380 KB |
Output is correct |
29 |
Correct |
5 ms |
1460 KB |
Output is correct |
30 |
Correct |
5 ms |
1580 KB |
Output is correct |
31 |
Correct |
5 ms |
1580 KB |
Output is correct |
32 |
Correct |
5 ms |
1712 KB |
Output is correct |
33 |
Correct |
6 ms |
1720 KB |
Output is correct |
34 |
Correct |
5 ms |
1800 KB |
Output is correct |
35 |
Correct |
5 ms |
1928 KB |
Output is correct |
36 |
Correct |
411 ms |
16240 KB |
Output is correct |
37 |
Correct |
407 ms |
20400 KB |
Output is correct |
38 |
Correct |
155 ms |
20400 KB |
Output is correct |
39 |
Correct |
387 ms |
26016 KB |
Output is correct |
40 |
Correct |
393 ms |
29372 KB |
Output is correct |
41 |
Correct |
412 ms |
33512 KB |
Output is correct |
42 |
Correct |
196 ms |
34108 KB |
Output is correct |
43 |
Correct |
141 ms |
35752 KB |
Output is correct |
44 |
Correct |
443 ms |
44500 KB |
Output is correct |
45 |
Correct |
455 ms |
52192 KB |
Output is correct |
46 |
Correct |
447 ms |
59832 KB |
Output is correct |
47 |
Correct |
445 ms |
67224 KB |
Output is correct |
48 |
Correct |
438 ms |
75612 KB |
Output is correct |
49 |
Correct |
429 ms |
82628 KB |
Output is correct |
50 |
Correct |
448 ms |
91016 KB |
Output is correct |