Submission #1163573

#TimeUsernameProblemLanguageResultExecution timeMemory
1163573siewjhVolontiranje (COCI21_volontiranje)C++20
10 / 110
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int nums; cin >> nums; vector<int> inc; vector<vector<pair<int, int>>> hist; for (int i = 1; i <= nums; i++){ int x; cin >> x; if (inc.empty() || x > inc.back()){ inc.push_back(x); hist.push_back({}); hist.back().push_back({x, i}); } else{ auto it = lower_bound(inc.begin(), inc.end(), x + 1); int id = it - inc.begin(); *it = x; hist[id].push_back({x, i}); } } vector<vector<int>> ans; int len = inc.size(); while (1){ vector<int> temp(len); int ok = 2; int prv = nums + 1, pid = nums + 1; for (int i = len - 1; i >= 0; i--){ while (!hist[i].empty() && hist[i].back().second > pid) hist[i].pop_back(); if (hist[i].empty()){ ok = 0; break; } if (hist[i].back().first > prv){ ok = 1; break; } pid = temp[i] = hist[i].back().second; prv = hist[i].back().first; hist[i].pop_back(); } if (ok == 0) break; else if (ok == 1) continue; ans.push_back(temp); } cout << ans.size() << ' ' << len << '\n'; for (auto v : ans){ for (int x : v) cout << x << ' '; cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...