Submission #745250

# Submission time Handle Problem Language Result Execution time Memory
745250 2023-05-19T15:56:49 Z Ahmed57 Volontiranje (COCI21_volontiranje) C++17
50 / 110
1000 ms 8512 KB
#include <bits/stdc++.h>

using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v;
    for(int i = 0;i<n;i++){
        int x;cin>>x;
        v.push_back(x);
    }
    int be = 0, cnt = 0;
    vector<vector<int>> ans;
    bool ch[n] = {0};
    while(1){
        int dp[v.size()] = {0};
        int pr[v.size()] = {0};
        int all= -1 ,index = 0;
        for(int i=0 ;i<v.size();i++){
            if(ch[i])continue;
            int ma = 0, ind =i;
            for(int j = 0;j<i;j++){
                if(ch[j])continue;
                if(v[i]>v[j]){
                    if(ma<dp[j]){
                        ma=dp[j];
                        ind = j;
                    }
                }
            }
            dp[i] = ma+1;
            pr[i] = ind;
            if(all<dp[i]){
                all= dp[i];
                index = i;
            }
        }
        if(all<be){
            break;
        }
        cnt++;
        be = all;
        ans.push_back({});
        while(pr[index]!=index){
            ch[index]=1;
            ans.back().push_back(index);
            index= pr[index];
        }ans.back().push_back(index);
        ch[index] = 1;
    }
    cout<<cnt<<" "<<be<<endl;
    for(auto i:ans){
        reverse(i.begin(),i.end());
        for(auto j:i){
            cout<<j+1<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         for(int i=0 ;i<v.size();i++){
      |                      ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 2 ms 300 KB Output is correct
27 Correct 4 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 283 ms 300 KB Output is correct
31 Correct 9 ms 212 KB Output is correct
32 Correct 12 ms 316 KB Output is correct
33 Correct 124 ms 312 KB Output is correct
34 Correct 110 ms 300 KB Output is correct
35 Correct 118 ms 212 KB Output is correct
36 Correct 2 ms 212 KB Output is correct
37 Correct 2 ms 296 KB Output is correct
38 Correct 4 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 300 KB Output is correct
43 Correct 1 ms 300 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 304 KB Output is correct
26 Correct 2 ms 300 KB Output is correct
27 Correct 4 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 283 ms 300 KB Output is correct
31 Correct 9 ms 212 KB Output is correct
32 Correct 12 ms 316 KB Output is correct
33 Correct 124 ms 312 KB Output is correct
34 Correct 110 ms 300 KB Output is correct
35 Correct 118 ms 212 KB Output is correct
36 Correct 2 ms 212 KB Output is correct
37 Correct 2 ms 296 KB Output is correct
38 Correct 4 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 300 KB Output is correct
43 Correct 1 ms 300 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Execution timed out 1094 ms 8512 KB Time limit exceeded
48 Halted 0 ms 0 KB -