Submission #658389

# Submission time Handle Problem Language Result Execution time Memory
658389 2022-11-13T04:56:29 Z sam571128 Volontiranje (COCI21_volontiranje) C++17
110 / 110
290 ms 116652 KB
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long

using namespace std;

const int N = 1e6+5;
vector<int> num[N];
vector<vector<int>> ans;
int arr[N], dp[N];

signed main(){
    fastio
    int n;
    cin >> n;

    for(int i = 1; i <= n; i++){
        cin >> arr[i];
    }

    vector<int> lis;
    for(int i = 1; i <= n; i++){
        int idx = lower_bound(lis.begin(),lis.end(),arr[i])-lis.begin();
        if(idx==lis.size()) lis.push_back(arr[i]);
        else lis[idx] = arr[i];
        dp[i] = idx+1;
        num[idx+1].push_back(i);
    }

    int m = lis.size();
    for(int i = 1; i <= m; i++){
        reverse(num[i].begin(),num[i].end());
    }

    vector<int> tmp;
    int now = 1, idx = n+1;
    while(true){
        tmp.clear();
        for(int i = 1; i <= m; i++){
            while(!num[i].empty()){
                if(!tmp.empty()&&num[i].back() < tmp.back()) num[i].pop_back();
                else if(!tmp.empty() && arr[num[i].back()] < arr[tmp.back()]){
                    tmp.pop_back();
                    i -= 2;
                    goto popped;
                }
                else{
                    tmp.push_back(num[i].back());
                    num[i].pop_back();
                    break;
                }
            }
            if(tmp.size() < i){
                goto done;
            }
            popped:;
        }
        ans.push_back(tmp);
    }
    done:;

    cout << ans.size() << " " << m << "\n";
    for(auto v : ans){
        for(auto x : v){
            cout << x << " ";
        }
        cout << "\n";
    }
}   

/*
*/

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:25:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         if(idx==lis.size()) lis.push_back(arr[i]);
      |            ~~~^~~~~~~~~~~~
Main.cpp:54:27: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   54 |             if(tmp.size() < i){
      |                ~~~~~~~~~~~^~~
Main.cpp:37:9: warning: unused variable 'now' [-Wunused-variable]
   37 |     int now = 1, idx = n+1;
      |         ^~~
Main.cpp:37:18: warning: unused variable 'idx' [-Wunused-variable]
   37 |     int now = 1, idx = n+1;
      |                  ^~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23816 KB Output is correct
2 Correct 12 ms 23816 KB Output is correct
3 Correct 11 ms 23764 KB Output is correct
4 Correct 12 ms 23764 KB Output is correct
5 Correct 11 ms 23816 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23824 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 13 ms 23740 KB Output is correct
10 Correct 12 ms 23808 KB Output is correct
11 Correct 13 ms 23816 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 12 ms 23808 KB Output is correct
14 Correct 11 ms 23764 KB Output is correct
15 Correct 11 ms 23764 KB Output is correct
16 Correct 11 ms 23816 KB Output is correct
17 Correct 12 ms 23808 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 13 ms 23728 KB Output is correct
20 Correct 11 ms 23764 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 13 ms 23700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23816 KB Output is correct
2 Correct 12 ms 23816 KB Output is correct
3 Correct 11 ms 23764 KB Output is correct
4 Correct 12 ms 23764 KB Output is correct
5 Correct 11 ms 23816 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23824 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 13 ms 23740 KB Output is correct
10 Correct 12 ms 23808 KB Output is correct
11 Correct 13 ms 23816 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 12 ms 23808 KB Output is correct
14 Correct 11 ms 23764 KB Output is correct
15 Correct 11 ms 23764 KB Output is correct
16 Correct 11 ms 23816 KB Output is correct
17 Correct 12 ms 23808 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 13 ms 23728 KB Output is correct
20 Correct 11 ms 23764 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 13 ms 23700 KB Output is correct
24 Correct 13 ms 23764 KB Output is correct
25 Correct 15 ms 23740 KB Output is correct
26 Correct 13 ms 23764 KB Output is correct
27 Correct 14 ms 23764 KB Output is correct
28 Correct 12 ms 23736 KB Output is correct
29 Correct 13 ms 23892 KB Output is correct
30 Correct 13 ms 23832 KB Output is correct
31 Correct 12 ms 23764 KB Output is correct
32 Correct 15 ms 23816 KB Output is correct
33 Correct 14 ms 23836 KB Output is correct
34 Correct 12 ms 23764 KB Output is correct
35 Correct 14 ms 23808 KB Output is correct
36 Correct 16 ms 23792 KB Output is correct
37 Correct 13 ms 23808 KB Output is correct
38 Correct 14 ms 23764 KB Output is correct
39 Correct 12 ms 23764 KB Output is correct
40 Correct 12 ms 23764 KB Output is correct
41 Correct 12 ms 23760 KB Output is correct
42 Correct 12 ms 23708 KB Output is correct
43 Correct 13 ms 23764 KB Output is correct
44 Correct 12 ms 23764 KB Output is correct
45 Correct 12 ms 23764 KB Output is correct
46 Correct 14 ms 23804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 23816 KB Output is correct
2 Correct 12 ms 23816 KB Output is correct
3 Correct 11 ms 23764 KB Output is correct
4 Correct 12 ms 23764 KB Output is correct
5 Correct 11 ms 23816 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23824 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 13 ms 23740 KB Output is correct
10 Correct 12 ms 23808 KB Output is correct
11 Correct 13 ms 23816 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 12 ms 23808 KB Output is correct
14 Correct 11 ms 23764 KB Output is correct
15 Correct 11 ms 23764 KB Output is correct
16 Correct 11 ms 23816 KB Output is correct
17 Correct 12 ms 23808 KB Output is correct
18 Correct 12 ms 23764 KB Output is correct
19 Correct 13 ms 23728 KB Output is correct
20 Correct 11 ms 23764 KB Output is correct
21 Correct 12 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 13 ms 23700 KB Output is correct
24 Correct 13 ms 23764 KB Output is correct
25 Correct 15 ms 23740 KB Output is correct
26 Correct 13 ms 23764 KB Output is correct
27 Correct 14 ms 23764 KB Output is correct
28 Correct 12 ms 23736 KB Output is correct
29 Correct 13 ms 23892 KB Output is correct
30 Correct 13 ms 23832 KB Output is correct
31 Correct 12 ms 23764 KB Output is correct
32 Correct 15 ms 23816 KB Output is correct
33 Correct 14 ms 23836 KB Output is correct
34 Correct 12 ms 23764 KB Output is correct
35 Correct 14 ms 23808 KB Output is correct
36 Correct 16 ms 23792 KB Output is correct
37 Correct 13 ms 23808 KB Output is correct
38 Correct 14 ms 23764 KB Output is correct
39 Correct 12 ms 23764 KB Output is correct
40 Correct 12 ms 23764 KB Output is correct
41 Correct 12 ms 23760 KB Output is correct
42 Correct 12 ms 23708 KB Output is correct
43 Correct 13 ms 23764 KB Output is correct
44 Correct 12 ms 23764 KB Output is correct
45 Correct 12 ms 23764 KB Output is correct
46 Correct 14 ms 23804 KB Output is correct
47 Correct 84 ms 37308 KB Output is correct
48 Correct 96 ms 37984 KB Output is correct
49 Correct 100 ms 43040 KB Output is correct
50 Correct 182 ms 57036 KB Output is correct
51 Correct 50 ms 31504 KB Output is correct
52 Correct 270 ms 115852 KB Output is correct
53 Correct 290 ms 116652 KB Output is correct
54 Correct 195 ms 69216 KB Output is correct
55 Correct 202 ms 69052 KB Output is correct
56 Correct 13 ms 24140 KB Output is correct
57 Correct 139 ms 50736 KB Output is correct
58 Correct 50 ms 30024 KB Output is correct
59 Correct 35 ms 29172 KB Output is correct
60 Correct 141 ms 51128 KB Output is correct
61 Correct 95 ms 41464 KB Output is correct
62 Correct 11 ms 23764 KB Output is correct
63 Correct 11 ms 23808 KB Output is correct
64 Correct 12 ms 23764 KB Output is correct
65 Correct 11 ms 23800 KB Output is correct
66 Correct 12 ms 23764 KB Output is correct
67 Correct 14 ms 23720 KB Output is correct
68 Correct 13 ms 23808 KB Output is correct
69 Correct 13 ms 23760 KB Output is correct