Submission #1019609

# Submission time Handle Problem Language Result Execution time Memory
1019609 2024-07-11T05:02:28 Z TAhmed33 Volontiranje (COCI21_volontiranje) C++
110 / 110
206 ms 105104 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e6 + 25;
int p[MAXN], n;
int cur[MAXN];
vector <int> dd[MAXN];
void solve () {
    cin >> n;
    cur[0] = -MAXN;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        cur[i] = MAXN;
    }
    int v = 0;
    for (int i = 1; i <= n; i++) {
        int g = upper_bound(cur, cur + n + 1, p[i]) - cur;
        dd[g].push_back(i);
        cur[g] = p[i];
        v = max(v, g);
    }
    for (int i = 1; i <= v; i++) {
        reverse(dd[i].begin(), dd[i].end());
    }
    vector <vector <int>> ans;
    while (true) {
        bool f = 0;
        for (int i = 1; i < v; i++) {
            if (dd[i].empty() || dd[i + 1].empty()) {
                f = 1;
                break;
            }
            while (!dd[i + 1].empty() && dd[i + 1].back() < dd[i].back()) {
                dd[i + 1].pop_back();
            }
            if (p[dd[i + 1].back()] < p[dd[i].back()]) {
                dd[i].pop_back();
                i -= 2; if (i == -1) i = 0;
            }
        }
        if (f) {
            break;
        }
        vector <int> gg;
        for (int i = 1; i <= v; i++) {
            if (dd[i].empty()) {
                f = 1;
                break;
            }
            gg.push_back(dd[i].back());
            dd[i].pop_back();
        }
        if (f) {
            break;
        }
        ans.push_back(gg);
    }
    cout << int(ans.size()) << ' ' << v << '\n';
    for (auto i : ans) {
        for (auto j : i) {
            cout << j << " ";
        }
        cout << '\n';
    }
    return;
}       
signed main () {
    ios::sync_with_stdio(0); cin.tie(0);
    int tc = 1; //cin >> tc;
    while (tc--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23896 KB Output is correct
2 Correct 11 ms 23900 KB Output is correct
3 Correct 11 ms 23900 KB Output is correct
4 Correct 10 ms 23900 KB Output is correct
5 Correct 11 ms 23900 KB Output is correct
6 Correct 10 ms 23900 KB Output is correct
7 Correct 10 ms 23900 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23896 KB Output is correct
10 Correct 10 ms 23944 KB Output is correct
11 Correct 10 ms 23900 KB Output is correct
12 Correct 11 ms 23896 KB Output is correct
13 Correct 11 ms 23900 KB Output is correct
14 Correct 10 ms 23944 KB Output is correct
15 Correct 10 ms 23948 KB Output is correct
16 Correct 10 ms 24152 KB Output is correct
17 Correct 11 ms 23896 KB Output is correct
18 Correct 12 ms 23876 KB Output is correct
19 Correct 11 ms 23896 KB Output is correct
20 Correct 10 ms 23900 KB Output is correct
21 Correct 11 ms 23900 KB Output is correct
22 Correct 10 ms 23900 KB Output is correct
23 Correct 10 ms 23896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23896 KB Output is correct
2 Correct 11 ms 23900 KB Output is correct
3 Correct 11 ms 23900 KB Output is correct
4 Correct 10 ms 23900 KB Output is correct
5 Correct 11 ms 23900 KB Output is correct
6 Correct 10 ms 23900 KB Output is correct
7 Correct 10 ms 23900 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23896 KB Output is correct
10 Correct 10 ms 23944 KB Output is correct
11 Correct 10 ms 23900 KB Output is correct
12 Correct 11 ms 23896 KB Output is correct
13 Correct 11 ms 23900 KB Output is correct
14 Correct 10 ms 23944 KB Output is correct
15 Correct 10 ms 23948 KB Output is correct
16 Correct 10 ms 24152 KB Output is correct
17 Correct 11 ms 23896 KB Output is correct
18 Correct 12 ms 23876 KB Output is correct
19 Correct 11 ms 23896 KB Output is correct
20 Correct 10 ms 23900 KB Output is correct
21 Correct 11 ms 23900 KB Output is correct
22 Correct 10 ms 23900 KB Output is correct
23 Correct 10 ms 23896 KB Output is correct
24 Correct 11 ms 23896 KB Output is correct
25 Correct 13 ms 23900 KB Output is correct
26 Correct 10 ms 23896 KB Output is correct
27 Correct 11 ms 23884 KB Output is correct
28 Correct 10 ms 23900 KB Output is correct
29 Correct 13 ms 23804 KB Output is correct
30 Correct 13 ms 23980 KB Output is correct
31 Correct 10 ms 23900 KB Output is correct
32 Correct 10 ms 23900 KB Output is correct
33 Correct 11 ms 23844 KB Output is correct
34 Correct 10 ms 23900 KB Output is correct
35 Correct 10 ms 23804 KB Output is correct
36 Correct 11 ms 23896 KB Output is correct
37 Correct 10 ms 23900 KB Output is correct
38 Correct 10 ms 23900 KB Output is correct
39 Correct 13 ms 23900 KB Output is correct
40 Correct 10 ms 23860 KB Output is correct
41 Correct 10 ms 23896 KB Output is correct
42 Correct 10 ms 23956 KB Output is correct
43 Correct 10 ms 23896 KB Output is correct
44 Correct 10 ms 23900 KB Output is correct
45 Correct 11 ms 23896 KB Output is correct
46 Correct 11 ms 23936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 23896 KB Output is correct
2 Correct 11 ms 23900 KB Output is correct
3 Correct 11 ms 23900 KB Output is correct
4 Correct 10 ms 23900 KB Output is correct
5 Correct 11 ms 23900 KB Output is correct
6 Correct 10 ms 23900 KB Output is correct
7 Correct 10 ms 23900 KB Output is correct
8 Correct 10 ms 23900 KB Output is correct
9 Correct 10 ms 23896 KB Output is correct
10 Correct 10 ms 23944 KB Output is correct
11 Correct 10 ms 23900 KB Output is correct
12 Correct 11 ms 23896 KB Output is correct
13 Correct 11 ms 23900 KB Output is correct
14 Correct 10 ms 23944 KB Output is correct
15 Correct 10 ms 23948 KB Output is correct
16 Correct 10 ms 24152 KB Output is correct
17 Correct 11 ms 23896 KB Output is correct
18 Correct 12 ms 23876 KB Output is correct
19 Correct 11 ms 23896 KB Output is correct
20 Correct 10 ms 23900 KB Output is correct
21 Correct 11 ms 23900 KB Output is correct
22 Correct 10 ms 23900 KB Output is correct
23 Correct 10 ms 23896 KB Output is correct
24 Correct 11 ms 23896 KB Output is correct
25 Correct 13 ms 23900 KB Output is correct
26 Correct 10 ms 23896 KB Output is correct
27 Correct 11 ms 23884 KB Output is correct
28 Correct 10 ms 23900 KB Output is correct
29 Correct 13 ms 23804 KB Output is correct
30 Correct 13 ms 23980 KB Output is correct
31 Correct 10 ms 23900 KB Output is correct
32 Correct 10 ms 23900 KB Output is correct
33 Correct 11 ms 23844 KB Output is correct
34 Correct 10 ms 23900 KB Output is correct
35 Correct 10 ms 23804 KB Output is correct
36 Correct 11 ms 23896 KB Output is correct
37 Correct 10 ms 23900 KB Output is correct
38 Correct 10 ms 23900 KB Output is correct
39 Correct 13 ms 23900 KB Output is correct
40 Correct 10 ms 23860 KB Output is correct
41 Correct 10 ms 23896 KB Output is correct
42 Correct 10 ms 23956 KB Output is correct
43 Correct 10 ms 23896 KB Output is correct
44 Correct 10 ms 23900 KB Output is correct
45 Correct 11 ms 23896 KB Output is correct
46 Correct 11 ms 23936 KB Output is correct
47 Correct 66 ms 32004 KB Output is correct
48 Correct 62 ms 32456 KB Output is correct
49 Correct 77 ms 35304 KB Output is correct
50 Correct 127 ms 43696 KB Output is correct
51 Correct 36 ms 28496 KB Output is correct
52 Correct 188 ms 84328 KB Output is correct
53 Correct 206 ms 105104 KB Output is correct
54 Correct 143 ms 53328 KB Output is correct
55 Correct 154 ms 53200 KB Output is correct
56 Correct 12 ms 23984 KB Output is correct
57 Correct 103 ms 40016 KB Output is correct
58 Correct 37 ms 27472 KB Output is correct
59 Correct 28 ms 26988 KB Output is correct
60 Correct 118 ms 40228 KB Output is correct
61 Correct 72 ms 34384 KB Output is correct
62 Correct 10 ms 23896 KB Output is correct
63 Correct 10 ms 23900 KB Output is correct
64 Correct 10 ms 23900 KB Output is correct
65 Correct 10 ms 23784 KB Output is correct
66 Correct 10 ms 23900 KB Output is correct
67 Correct 11 ms 23784 KB Output is correct
68 Correct 11 ms 23900 KB Output is correct
69 Correct 10 ms 23896 KB Output is correct