# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57545 |
2018-07-15T08:30:17 Z |
노영훈(#1670) |
Teams (CEOI11_tea) |
C++11 |
|
474 ms |
77932 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=1000010, inf=2e9;
int n;
struct stu {
int a, idx, cut, cnt, mx;
} S[MX];
vector<int> V, W[MX];
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n;
for(int i=1; i<=n; i++){
cin>>S[i].a; S[i].idx=i;
}
sort(S+1, S+n+1, [](stu &a, stu &b){
return a.a<b.a;
});
V.push_back(0);
W[0].push_back(0);
for(int i=1; i<=n; i++){
// cout<<"QUEUE: \n";
// for(int x:V) cout<<x<<' ';
// cout<<"\n\n";
S[i].cut=-1, S[i].cnt=-1, S[i].mx=inf;
auto it=upper_bound(V.begin(), V.end(), i-S[i].a);
if(it==V.begin()) continue;
it--; int j=*it;
// cout<<i<<' '<<j<<'\n';
int cnt=S[i].cnt=S[j].cnt+1;
if(S[V.back()].cnt<cnt) V.push_back(i);
vector<int> &U=W[cnt-1];
int s=0, e=U.size()-1;
while(s+5<e){
int m1=(s*2+e)/3, m2=(s+2*e)/3;
int x1=max(S[U[m1]].mx, i-U[m1]);
int x2=max(S[U[m2]].mx, i-U[m2]);
if(x1<=x2) e=m2;
else s=m1;
}
for(int j=s; j<=e; j++){
int now=max(S[U[j]].mx, i-U[j]);
if(S[i].mx>now) S[i].mx=now, S[i].cut=U[j];
}
if(!W[cnt].empty() && S[W[cnt].back()].mx==S[i].mx) W[cnt].pop_back();
if(W[cnt].empty() || S[W[cnt].back()].mx<S[i].mx) W[cnt].push_back(i);
}
// for(int i=1; i<=n; i++)
// cout<<i<<' '<<S[i].a<<' '<<S[i].cut<<' '<<S[i].cnt<<' '<<S[i].mx<<'\n';
vector<vector<int>> ans;
int now=n;
while(now>0){
vector<int> put;
for(int i=now; i>S[now].cut; i--)
put.push_back(S[i].idx);
ans.push_back(put);
now=S[now].cut;
}
cout<<ans.size()<<'\n';
for(auto &V:ans){
cout<<V.size()<<' ';
for(int x:V) cout<<x<<' ';
cout<<'\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
23804 KB |
Output is correct |
2 |
Incorrect |
21 ms |
23912 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
23912 KB |
Output is correct |
2 |
Incorrect |
24 ms |
23916 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
24 ms |
24008 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
24248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
24268 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
60 ms |
27032 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
27868 KB |
Output is correct |
2 |
Incorrect |
43 ms |
27876 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
372 ms |
52036 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
474 ms |
66776 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
430 ms |
77932 KB |
Output is correct |
2 |
Correct |
299 ms |
77932 KB |
Output is correct |
3 |
Incorrect |
356 ms |
77932 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |