# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
851918 | 2023-09-20T19:35:48 Z | serifefedartar | Volontiranje (COCI21_volontiranje) | C++17 | 1 ms | 2396 KB |
#include <bits/stdc++.h> using namespace std; #define fast ios::sync_with_stdio(0);cin.tie(0); #define s second #define f first typedef long long ll; const ll MOD = 1e9 + 7; const ll LOGN = 20; const ll MAXN = 1e6 + 5; vector<int> A; int pos[MAXN]; int n, vis[MAXN]; vector<int> find_LIS() { vector<int> LIS; for (int i = 1; i <= n; i++) { if (vis[i]) continue; int q = upper_bound(LIS.begin(), LIS.end(), A[i]) - LIS.begin(); if (q == LIS.size()) LIS.push_back(A[i]); LIS[q] = A[i]; } return LIS; } int main() { fast cin >> n; A = vector<int>(n+1); for (int i = 1; i <= n; i++) { cin >> A[i]; pos[A[i]] = i; } int mx = 0; vector<vector<int>> ans; for (int i = 1; i <= n; i++) { vector<int> LIS = find_LIS(); if (LIS.size() < mx) break; mx = max(mx, (int)LIS.size()); for (auto u : LIS) vis[pos[u]] = true; ans.push_back(LIS); } cout << ans.size() << " " << ans[0].size() << "\n"; for (auto u : ans) { for (auto item : u) cout << pos[item] << " "; cout << "\n"; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Subsequence indices should be sorted |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Subsequence indices should be sorted |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2396 KB | Subsequence indices should be sorted |
2 | Halted | 0 ms | 0 KB | - |