# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
637480 |
2022-09-02T05:26:28 Z |
Arinoor |
LIS (INOI20_lis) |
C++17 |
|
1592 ms |
128356 KB |
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define bug2(x, y) cout << #x << ' ' << #y << " : " << x << ' ' << y << endl
#define bug(x) cout << #x << " : " << x << endl
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 1e6 + 10;
const int maxlg = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 10;
int q, ind[maxn], a[maxn], dp[maxn], ans;
int fen[maxn];
pii Q[maxn];
set<int> S[maxn];
void add(int i, int x){
for(; i <= q; i += i & -i)
fen[i] += x;
}
int get(int x){
int ind = 0;
for(int i = maxlg - 1; ~i; i --){
int j = ind + (1 << i);
if(j <= q and fen[j] < x){
ind = j;
x -= fen[j];
}
}
return ++ind;
}
void dfs(int i){
int x = dp[i] + 1;
while(true){
auto it = S[x].upper_bound(i);
if(it == S[x].end() or a[*it] <= a[i])
break;
dfs(*it);
}
S[dp[i]].erase(i);
dp[i] = x;
S[dp[i]].insert(i);
ans = max(ans, x);
}
int main(){
ios;
cin >> q;
for(int i = 0; i < q; i ++){
cin >> Q[i].fi >> Q[i].se;
}
for(int i = 1; i <= q; i ++){
add(i, 1);
}
for(int i = q - 1; ~i; i --){
ind[i] = get(Q[i].fi);
a[ind[i]] = Q[i].se;
add(ind[i], -1);
}
for(int i = 0; i < q; i ++){
int j = ind[i];
dp[j] = 1;
while(true){
auto it = S[dp[j]].lower_bound(j);
if(it == S[dp[j]].begin())
break;
it --;
if(a[*it] < a[j])
dp[j] ++;
else
break;
}
dp[j] --;
dfs(j);
cout << ans << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
47316 KB |
Output is correct |
2 |
Correct |
24 ms |
47328 KB |
Output is correct |
3 |
Correct |
26 ms |
47384 KB |
Output is correct |
4 |
Correct |
29 ms |
47480 KB |
Output is correct |
5 |
Correct |
39 ms |
47424 KB |
Output is correct |
6 |
Correct |
30 ms |
47444 KB |
Output is correct |
7 |
Correct |
27 ms |
47444 KB |
Output is correct |
8 |
Correct |
27 ms |
47444 KB |
Output is correct |
9 |
Correct |
28 ms |
47496 KB |
Output is correct |
10 |
Correct |
24 ms |
47444 KB |
Output is correct |
11 |
Correct |
28 ms |
47444 KB |
Output is correct |
12 |
Correct |
32 ms |
47436 KB |
Output is correct |
13 |
Correct |
31 ms |
47412 KB |
Output is correct |
14 |
Correct |
28 ms |
47452 KB |
Output is correct |
15 |
Correct |
26 ms |
47436 KB |
Output is correct |
16 |
Correct |
27 ms |
47492 KB |
Output is correct |
17 |
Correct |
29 ms |
47396 KB |
Output is correct |
18 |
Correct |
28 ms |
47388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
47316 KB |
Output is correct |
2 |
Correct |
24 ms |
47328 KB |
Output is correct |
3 |
Correct |
26 ms |
47384 KB |
Output is correct |
4 |
Correct |
29 ms |
47480 KB |
Output is correct |
5 |
Correct |
39 ms |
47424 KB |
Output is correct |
6 |
Correct |
30 ms |
47444 KB |
Output is correct |
7 |
Correct |
27 ms |
47444 KB |
Output is correct |
8 |
Correct |
27 ms |
47444 KB |
Output is correct |
9 |
Correct |
28 ms |
47496 KB |
Output is correct |
10 |
Correct |
24 ms |
47444 KB |
Output is correct |
11 |
Correct |
28 ms |
47444 KB |
Output is correct |
12 |
Correct |
32 ms |
47436 KB |
Output is correct |
13 |
Correct |
31 ms |
47412 KB |
Output is correct |
14 |
Correct |
28 ms |
47452 KB |
Output is correct |
15 |
Correct |
26 ms |
47436 KB |
Output is correct |
16 |
Correct |
27 ms |
47492 KB |
Output is correct |
17 |
Correct |
29 ms |
47396 KB |
Output is correct |
18 |
Correct |
28 ms |
47388 KB |
Output is correct |
19 |
Correct |
202 ms |
61924 KB |
Output is correct |
20 |
Correct |
170 ms |
62024 KB |
Output is correct |
21 |
Correct |
287 ms |
61284 KB |
Output is correct |
22 |
Correct |
356 ms |
61460 KB |
Output is correct |
23 |
Correct |
219 ms |
62032 KB |
Output is correct |
24 |
Correct |
242 ms |
62028 KB |
Output is correct |
25 |
Correct |
237 ms |
62020 KB |
Output is correct |
26 |
Correct |
245 ms |
61980 KB |
Output is correct |
27 |
Correct |
244 ms |
62028 KB |
Output is correct |
28 |
Correct |
239 ms |
62040 KB |
Output is correct |
29 |
Correct |
218 ms |
62084 KB |
Output is correct |
30 |
Correct |
276 ms |
62044 KB |
Output is correct |
31 |
Correct |
381 ms |
62176 KB |
Output is correct |
32 |
Correct |
363 ms |
62056 KB |
Output is correct |
33 |
Correct |
363 ms |
61964 KB |
Output is correct |
34 |
Correct |
345 ms |
62072 KB |
Output is correct |
35 |
Correct |
384 ms |
62004 KB |
Output is correct |
36 |
Correct |
344 ms |
61936 KB |
Output is correct |
37 |
Correct |
368 ms |
62012 KB |
Output is correct |
38 |
Correct |
365 ms |
62040 KB |
Output is correct |
39 |
Correct |
351 ms |
61992 KB |
Output is correct |
40 |
Correct |
376 ms |
62092 KB |
Output is correct |
41 |
Correct |
168 ms |
58860 KB |
Output is correct |
42 |
Correct |
46 ms |
49624 KB |
Output is correct |
43 |
Correct |
225 ms |
58028 KB |
Output is correct |
44 |
Correct |
195 ms |
54988 KB |
Output is correct |
45 |
Correct |
36 ms |
48476 KB |
Output is correct |
46 |
Correct |
28 ms |
47568 KB |
Output is correct |
47 |
Correct |
84 ms |
52712 KB |
Output is correct |
48 |
Correct |
63 ms |
51076 KB |
Output is correct |
49 |
Correct |
31 ms |
48184 KB |
Output is correct |
50 |
Correct |
27 ms |
47548 KB |
Output is correct |
51 |
Correct |
64 ms |
50704 KB |
Output is correct |
52 |
Correct |
145 ms |
56780 KB |
Output is correct |
53 |
Correct |
120 ms |
55320 KB |
Output is correct |
54 |
Correct |
126 ms |
54348 KB |
Output is correct |
55 |
Correct |
42 ms |
49008 KB |
Output is correct |
56 |
Correct |
140 ms |
53072 KB |
Output is correct |
57 |
Correct |
66 ms |
49836 KB |
Output is correct |
58 |
Correct |
69 ms |
49500 KB |
Output is correct |
59 |
Correct |
36 ms |
47892 KB |
Output is correct |
60 |
Correct |
188 ms |
55816 KB |
Output is correct |
61 |
Correct |
25 ms |
47428 KB |
Output is correct |
62 |
Correct |
98 ms |
51384 KB |
Output is correct |
63 |
Correct |
63 ms |
49592 KB |
Output is correct |
64 |
Correct |
138 ms |
53428 KB |
Output is correct |
65 |
Correct |
119 ms |
52728 KB |
Output is correct |
66 |
Correct |
50 ms |
48836 KB |
Output is correct |
67 |
Correct |
106 ms |
51744 KB |
Output is correct |
68 |
Correct |
70 ms |
50208 KB |
Output is correct |
69 |
Correct |
118 ms |
52684 KB |
Output is correct |
70 |
Correct |
42 ms |
48536 KB |
Output is correct |
71 |
Correct |
1571 ms |
128280 KB |
Output is correct |
72 |
Correct |
1563 ms |
128264 KB |
Output is correct |
73 |
Correct |
1592 ms |
128224 KB |
Output is correct |
74 |
Correct |
1507 ms |
128356 KB |
Output is correct |
75 |
Correct |
1558 ms |
128072 KB |
Output is correct |
76 |
Correct |
1493 ms |
128160 KB |
Output is correct |