Submission #985677

#TimeUsernameProblemLanguageResultExecution timeMemory
985677rembocoderVolontiranje (COCI21_volontiranje)C++17
50 / 110
1038 ms9564 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t // const int mod = 1e9 + 7; const int inf = 2e18; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<bool> del(n, false); int ans = -1; vector<vector<int>> seqs; while (true) { vector<int> dp(n, -inf); for (int i = n - 1; i >= 0; i--) { if (del[i]) { continue; } dp[i] = 1; for (int j = i + 1; j < n; j++) { if (!del[j] && a[j] > a[i]) { dp[i] = max(dp[i], dp[j] + 1); } } } int cur = -inf; for (int i = 0; i < n; i++) { if (!del[i]) { cur = max(cur, dp[i]); } } if (ans == -1) { ans = cur; } else if (ans != cur) { break; } seqs.push_back({}); int last = -1; for (int i = 0; i < n; i++) { if (del[i] || dp[i] != cur || (last != -1 && a[i] <= a[last])) { continue; } last = i; cur--; seqs.back().push_back(i); del[i] = true; } } cout << seqs.size() << ' ' << ans << '\n'; for (int i = 0; i < seqs.size(); i++) { for (int x: seqs[i]) { cout << x + 1 << ' '; } cout << '\n'; } }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::vector<long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = 0; i < seqs.size(); i++) {
      |                     ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...