# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
172770 | 2020-01-02T15:03:26 Z | arnold518 | Matryoshka (JOI16_matryoshka) | C++14 | 473 ms | 13264 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 4e5; struct Point { int x, y, p; }; int N, Q, ans[MAXN+10]; Point A[MAXN+10]; vector<int> xcomp, ycomp; int tree[MAXN+10]; void update(int i, int val) { for(; i<=xcomp.size(); i+=(i&-i)) tree[i]=max(tree[i], val); } int query(int i) { int ret=0; for(; i>0; i-=(i&-i)) ret=max(ret, tree[i]); return ret; } int main() { int i, j; scanf("%d%d", &N, &Q); for(i=1; i<=N; i++) { scanf("%d%d", &A[i].x, &A[i].y); A[i].x*=-1; A[i].p=-1; xcomp.push_back(A[i].x); ycomp.push_back(A[i].y); } for(i=N+1; i<=N+Q; i++) { scanf("%d%d", &A[i].x, &A[i].y); A[i].x*=-1; A[i].p=i-N; xcomp.push_back(A[i].x); ycomp.push_back(A[i].y); } sort(xcomp.begin(), xcomp.end()); sort(ycomp.begin(), ycomp.end()); xcomp.erase(unique(xcomp.begin(), xcomp.end()), xcomp.end()); ycomp.erase(unique(ycomp.begin(), ycomp.end()), ycomp.end()); for(i=1; i<=N+Q; i++) A[i].x=lower_bound(xcomp.begin(), xcomp.end(), A[i].x)-xcomp.begin()+1; for(i=1; i<=N+Q; i++) A[i].y=lower_bound(ycomp.begin(), ycomp.end(), A[i].y)-ycomp.begin()+1; sort(A+1, A+N+Q+1, [&](const Point &p, const Point &q) { if(pii(p.y, p.x)!=pii(q.y, q.x)) return pii(p.y, p.x)<pii(q.y, q.x); else return p.p<q.p; }); for(i=1; i<=N+Q; i++) { if(A[i].p==-1) update(A[i].x, query(A[i].x)+1); else ans[A[i].p]=query(A[i].x); } for(i=1; i<=Q; i++) printf("%d\n", ans[i]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 1 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 380 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 1 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 380 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 1 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 1 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 380 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 1 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 380 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 504 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 504 KB | Output is correct |
26 | Correct | 5 ms | 504 KB | Output is correct |
27 | Correct | 5 ms | 504 KB | Output is correct |
28 | Correct | 5 ms | 504 KB | Output is correct |
29 | Correct | 5 ms | 504 KB | Output is correct |
30 | Correct | 4 ms | 504 KB | Output is correct |
31 | Correct | 5 ms | 504 KB | Output is correct |
32 | Correct | 5 ms | 504 KB | Output is correct |
33 | Correct | 5 ms | 504 KB | Output is correct |
34 | Correct | 5 ms | 504 KB | Output is correct |
35 | Correct | 5 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 1 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 380 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 1 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 380 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 3 ms | 376 KB | Output is correct |
23 | Correct | 5 ms | 504 KB | Output is correct |
24 | Correct | 5 ms | 376 KB | Output is correct |
25 | Correct | 5 ms | 504 KB | Output is correct |
26 | Correct | 5 ms | 504 KB | Output is correct |
27 | Correct | 5 ms | 504 KB | Output is correct |
28 | Correct | 5 ms | 504 KB | Output is correct |
29 | Correct | 5 ms | 504 KB | Output is correct |
30 | Correct | 4 ms | 504 KB | Output is correct |
31 | Correct | 5 ms | 504 KB | Output is correct |
32 | Correct | 5 ms | 504 KB | Output is correct |
33 | Correct | 5 ms | 504 KB | Output is correct |
34 | Correct | 5 ms | 504 KB | Output is correct |
35 | Correct | 5 ms | 504 KB | Output is correct |
36 | Correct | 422 ms | 11008 KB | Output is correct |
37 | Correct | 352 ms | 12376 KB | Output is correct |
38 | Correct | 147 ms | 4832 KB | Output is correct |
39 | Correct | 282 ms | 10508 KB | Output is correct |
40 | Correct | 282 ms | 10940 KB | Output is correct |
41 | Correct | 365 ms | 11600 KB | Output is correct |
42 | Correct | 191 ms | 10964 KB | Output is correct |
43 | Correct | 121 ms | 11224 KB | Output is correct |
44 | Correct | 472 ms | 12624 KB | Output is correct |
45 | Correct | 472 ms | 12908 KB | Output is correct |
46 | Correct | 469 ms | 12752 KB | Output is correct |
47 | Correct | 465 ms | 12624 KB | Output is correct |
48 | Correct | 466 ms | 13264 KB | Output is correct |
49 | Correct | 468 ms | 12640 KB | Output is correct |
50 | Correct | 473 ms | 13084 KB | Output is correct |