# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
872970 | 2023-11-14T07:58:18 Z | tsumondai | Volontiranje (COCI21_volontiranje) | C++14 | 206 ms | 109140 KB |
/* Tím dãy con tăng dài nhất và số lượng các dãy con đó cũng như liệt kê các chỉ số của chúng! */ #include <bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) #define __TIME (1.0 * clock() / CLOCKS_PER_SEC) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 1e6 + 5; const int oo = 1e18, mod = 1e9 + 7; int n, m, k, a[N]; vector<int> v[N], r, st; vector<vector<int>> out; // subtask 1: void build_LIS() { foru(i,1,n) { int pos=lower_bound(r.begin(), r.end(), a[i])-r.begin(); if (pos==r.size()) { r.pb(a[i]); } else { r[pos]=a[i]; } v[pos].pb(i); } foru(i,0,r.size()-1) { reverse(v[i].begin(), v[i].end()); } } void process() { while (1) { if (st.size()==0) { if (v[0].empty()) break; int pos=v[0].back(); v[0].pop_back(); st.pb(pos); } else if (st.size()==r.size()) { out.pb(st); st.clear(); } else { int k=st.size(); int curr=st.back(); while (!v[k].empty() && v[k].back() < curr) v[k].pop_back(); if (v[k].empty() || a[curr] > a[v[k].back()]) { st.pop_back(); } else { int pos=v[k].back(); v[k].pop_back(); st.push_back(pos); } } } } void trace() { cout << out.size() << ' ' << r.size() << '\n'; foru(i,0,out.size()-1) { for (auto x: out[i]) cout << x << ' '; cout << '\n'; } } signed main() { cin.tie(0)->sync_with_stdio(false); //freopen(".inp", "r", stdin); //freopen(".out", "w", stdout); cin >> n; foru(i,1,n) cin >> a[i]; build_LIS(); process(); trace(); cerr << "Time elapsed: " << __TIME << " s.\n"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 25180 KB | Output is correct |
2 | Correct | 6 ms | 25180 KB | Output is correct |
3 | Correct | 6 ms | 25180 KB | Output is correct |
4 | Correct | 5 ms | 25180 KB | Output is correct |
5 | Correct | 5 ms | 25268 KB | Output is correct |
6 | Correct | 6 ms | 25424 KB | Output is correct |
7 | Correct | 5 ms | 25272 KB | Output is correct |
8 | Correct | 5 ms | 25180 KB | Output is correct |
9 | Correct | 5 ms | 25216 KB | Output is correct |
10 | Correct | 6 ms | 25180 KB | Output is correct |
11 | Correct | 7 ms | 25180 KB | Output is correct |
12 | Correct | 5 ms | 25180 KB | Output is correct |
13 | Correct | 6 ms | 25180 KB | Output is correct |
14 | Correct | 5 ms | 25176 KB | Output is correct |
15 | Correct | 6 ms | 25180 KB | Output is correct |
16 | Correct | 6 ms | 25180 KB | Output is correct |
17 | Correct | 5 ms | 25180 KB | Output is correct |
18 | Correct | 5 ms | 25176 KB | Output is correct |
19 | Correct | 5 ms | 25180 KB | Output is correct |
20 | Correct | 5 ms | 25180 KB | Output is correct |
21 | Correct | 6 ms | 25180 KB | Output is correct |
22 | Correct | 6 ms | 25180 KB | Output is correct |
23 | Correct | 6 ms | 25176 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 25180 KB | Output is correct |
2 | Correct | 6 ms | 25180 KB | Output is correct |
3 | Correct | 6 ms | 25180 KB | Output is correct |
4 | Correct | 5 ms | 25180 KB | Output is correct |
5 | Correct | 5 ms | 25268 KB | Output is correct |
6 | Correct | 6 ms | 25424 KB | Output is correct |
7 | Correct | 5 ms | 25272 KB | Output is correct |
8 | Correct | 5 ms | 25180 KB | Output is correct |
9 | Correct | 5 ms | 25216 KB | Output is correct |
10 | Correct | 6 ms | 25180 KB | Output is correct |
11 | Correct | 7 ms | 25180 KB | Output is correct |
12 | Correct | 5 ms | 25180 KB | Output is correct |
13 | Correct | 6 ms | 25180 KB | Output is correct |
14 | Correct | 5 ms | 25176 KB | Output is correct |
15 | Correct | 6 ms | 25180 KB | Output is correct |
16 | Correct | 6 ms | 25180 KB | Output is correct |
17 | Correct | 5 ms | 25180 KB | Output is correct |
18 | Correct | 5 ms | 25176 KB | Output is correct |
19 | Correct | 5 ms | 25180 KB | Output is correct |
20 | Correct | 5 ms | 25180 KB | Output is correct |
21 | Correct | 6 ms | 25180 KB | Output is correct |
22 | Correct | 6 ms | 25180 KB | Output is correct |
23 | Correct | 6 ms | 25176 KB | Output is correct |
24 | Correct | 6 ms | 25180 KB | Output is correct |
25 | Correct | 6 ms | 25176 KB | Output is correct |
26 | Correct | 7 ms | 25176 KB | Output is correct |
27 | Correct | 6 ms | 25180 KB | Output is correct |
28 | Correct | 6 ms | 25176 KB | Output is correct |
29 | Correct | 6 ms | 25180 KB | Output is correct |
30 | Correct | 5 ms | 25180 KB | Output is correct |
31 | Correct | 6 ms | 25180 KB | Output is correct |
32 | Correct | 6 ms | 25180 KB | Output is correct |
33 | Correct | 6 ms | 25432 KB | Output is correct |
34 | Correct | 5 ms | 25180 KB | Output is correct |
35 | Correct | 6 ms | 25180 KB | Output is correct |
36 | Correct | 6 ms | 25180 KB | Output is correct |
37 | Correct | 5 ms | 25180 KB | Output is correct |
38 | Correct | 7 ms | 25180 KB | Output is correct |
39 | Correct | 6 ms | 25176 KB | Output is correct |
40 | Correct | 5 ms | 25180 KB | Output is correct |
41 | Correct | 5 ms | 25268 KB | Output is correct |
42 | Correct | 6 ms | 25180 KB | Output is correct |
43 | Correct | 6 ms | 25380 KB | Output is correct |
44 | Correct | 6 ms | 25180 KB | Output is correct |
45 | Correct | 6 ms | 25180 KB | Output is correct |
46 | Correct | 6 ms | 25180 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 25180 KB | Output is correct |
2 | Correct | 6 ms | 25180 KB | Output is correct |
3 | Correct | 6 ms | 25180 KB | Output is correct |
4 | Correct | 5 ms | 25180 KB | Output is correct |
5 | Correct | 5 ms | 25268 KB | Output is correct |
6 | Correct | 6 ms | 25424 KB | Output is correct |
7 | Correct | 5 ms | 25272 KB | Output is correct |
8 | Correct | 5 ms | 25180 KB | Output is correct |
9 | Correct | 5 ms | 25216 KB | Output is correct |
10 | Correct | 6 ms | 25180 KB | Output is correct |
11 | Correct | 7 ms | 25180 KB | Output is correct |
12 | Correct | 5 ms | 25180 KB | Output is correct |
13 | Correct | 6 ms | 25180 KB | Output is correct |
14 | Correct | 5 ms | 25176 KB | Output is correct |
15 | Correct | 6 ms | 25180 KB | Output is correct |
16 | Correct | 6 ms | 25180 KB | Output is correct |
17 | Correct | 5 ms | 25180 KB | Output is correct |
18 | Correct | 5 ms | 25176 KB | Output is correct |
19 | Correct | 5 ms | 25180 KB | Output is correct |
20 | Correct | 5 ms | 25180 KB | Output is correct |
21 | Correct | 6 ms | 25180 KB | Output is correct |
22 | Correct | 6 ms | 25180 KB | Output is correct |
23 | Correct | 6 ms | 25176 KB | Output is correct |
24 | Correct | 6 ms | 25180 KB | Output is correct |
25 | Correct | 6 ms | 25176 KB | Output is correct |
26 | Correct | 7 ms | 25176 KB | Output is correct |
27 | Correct | 6 ms | 25180 KB | Output is correct |
28 | Correct | 6 ms | 25176 KB | Output is correct |
29 | Correct | 6 ms | 25180 KB | Output is correct |
30 | Correct | 5 ms | 25180 KB | Output is correct |
31 | Correct | 6 ms | 25180 KB | Output is correct |
32 | Correct | 6 ms | 25180 KB | Output is correct |
33 | Correct | 6 ms | 25432 KB | Output is correct |
34 | Correct | 5 ms | 25180 KB | Output is correct |
35 | Correct | 6 ms | 25180 KB | Output is correct |
36 | Correct | 6 ms | 25180 KB | Output is correct |
37 | Correct | 5 ms | 25180 KB | Output is correct |
38 | Correct | 7 ms | 25180 KB | Output is correct |
39 | Correct | 6 ms | 25176 KB | Output is correct |
40 | Correct | 5 ms | 25180 KB | Output is correct |
41 | Correct | 5 ms | 25268 KB | Output is correct |
42 | Correct | 6 ms | 25180 KB | Output is correct |
43 | Correct | 6 ms | 25380 KB | Output is correct |
44 | Correct | 6 ms | 25180 KB | Output is correct |
45 | Correct | 6 ms | 25180 KB | Output is correct |
46 | Correct | 6 ms | 25180 KB | Output is correct |
47 | Correct | 68 ms | 34640 KB | Output is correct |
48 | Correct | 65 ms | 36688 KB | Output is correct |
49 | Correct | 80 ms | 39964 KB | Output is correct |
50 | Correct | 138 ms | 49588 KB | Output is correct |
51 | Correct | 35 ms | 31516 KB | Output is correct |
52 | Correct | 195 ms | 100352 KB | Output is correct |
53 | Correct | 206 ms | 109140 KB | Output is correct |
54 | Correct | 181 ms | 61224 KB | Output is correct |
55 | Correct | 150 ms | 61264 KB | Output is correct |
56 | Correct | 7 ms | 25436 KB | Output is correct |
57 | Correct | 108 ms | 46156 KB | Output is correct |
58 | Correct | 30 ms | 30692 KB | Output is correct |
59 | Correct | 27 ms | 28252 KB | Output is correct |
60 | Correct | 111 ms | 46536 KB | Output is correct |
61 | Correct | 73 ms | 38992 KB | Output is correct |
62 | Correct | 6 ms | 25180 KB | Output is correct |
63 | Correct | 6 ms | 25180 KB | Output is correct |
64 | Correct | 5 ms | 25176 KB | Output is correct |
65 | Correct | 5 ms | 25180 KB | Output is correct |
66 | Correct | 6 ms | 25268 KB | Output is correct |
67 | Correct | 5 ms | 25180 KB | Output is correct |
68 | Correct | 6 ms | 25180 KB | Output is correct |
69 | Correct | 5 ms | 25272 KB | Output is correct |