Submission #874623

# Submission time Handle Problem Language Result Execution time Memory
874623 2023-11-17T12:06:15 Z Youssif_Elkadi Volontiranje (COCI21_volontiranje) C++17
0 / 110
1 ms 436 KB
#include <bits/stdc++.h>
using namespace std;
const long long N = 5e2 + 5, inf = 1e17 + 5, mod = 998244353;
int main()
{
    ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
    int n;
    cin >> n;
    vector<int> arr(n + 1);
    for (int i = 1; i <= n; i++)
        cin >> arr[i];
    vector<int> dp(n + 1, 1);
    int mx = 1;
    for (int i = 1; i <= n; i++)
        for (int j = i - 1; j >= 1; j--)
            if (arr[j] < arr[i])
                dp[i] = max(dp[i], dp[j] + 1), mx = max(mx, dp[i]);
    vector<vector<int>> vec;
    vector<bool> vis(n + 1);
    for (int i = n; i >= 1; i--)
    {
        if (!vis[i] && dp[i] == mx)
        {
            vector<int> tmp;
            int cnt = mx;
            for (int j = i; j >= 1 && cnt; j--)
            {
                if (dp[j] == cnt && !vis[j])
                    tmp.push_back(j), cnt--, vis[j] = 1;
            }
            if (cnt == 0)
                vec.push_back(tmp);
        }
    }
    cout << vec.size() << " " << mx << "\n";
    for (auto v : vec)
    {
        for (int i = v.size() - 1; i >= 0; i--)
            cout << v[i] << " ";
        cout << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Incorrect 0 ms 348 KB Subsequence increasing
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Incorrect 0 ms 348 KB Subsequence increasing
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Incorrect 0 ms 348 KB Subsequence increasing
18 Halted 0 ms 0 KB -