Submission #532464

#TimeUsernameProblemLanguageResultExecution timeMemory
532464definitelynotmeeTeams (CEOI11_tea)C++98
0 / 100
297 ms35728 KiB
#include<bits/stdc++.h> #define mp make_pair #define mt make_tuple #define all(x) x.begin(), x.end() #define ff first #define ss second using namespace std; template <typename T> using matrix = vector<vector<T>>; typedef unsigned int uint; typedef unsigned long long ull; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll INFL = (1LL<<62)-1; const int INF = (1<<30)-1; const double EPS = 1e-7; const int MOD = 1e9 + 7; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); const int MAXN = 1e6+1; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> v(n+1); for(int i = 1; i <= n; i++) cin >> v[i]; vector<int> o(n+1); iota(all(o),0); stable_sort(1+all(o),[&](int a, int b){return v[a] < v[b];}); vector<pii> dp(n+1); priority_queue<pii> q; q.push({-INF,-INF}); int ptr = -1; for(int i = 1; i <= n; i++){ while(ptr < i-v[o[i]]){ ptr++; if(ptr>=0) q.push({dp[ptr].ff,ptr}); } ptr = min(ptr,i-v[o[i]]); int timer = 0; while(q.top().ss > ptr) q.pop(); dp[i] = q.top(); dp[i].ff++; } matrix<int> resp; resp.reserve(dp[n].ff); int id = n; while(id){ //cout << id << ' ' << dp[id].ss << endl; resp.push_back({}); for(int i = id; i > dp[id].ss; i--){ resp.back().push_back(o[i]); } id = dp[id].ss; } cout << resp.size() << '\n'; for(vector<int>& i : resp){ cout << i.size() << ' '; for(int j : i ) cout << j << ' '; cout << '\n'; } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:49:13: warning: unused variable 'timer' [-Wunused-variable]
   49 |         int timer = 0;
      |             ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...