Submission #57453

# Submission time Handle Problem Language Result Execution time Memory
57453 2018-07-15T05:29:24 Z 노영훈(#1670) Teams (CEOI11_tea) C++11
50 / 100
2500 ms 20252 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];

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;
    });

    // deque<node> Q;

    for(int i=1; i<=n; i++){
        S[i].cut=-1, S[i].cnt=-1, S[i].mx=inf;
        for(int j=i-S[i].a; j>=0; j--){
            if(S[j].cut<0) continue;
            if(S[i].cnt<S[j].cnt+1 || (S[i].cnt==S[j].cnt+1 && S[i].mx>max(S[j].mx, i-j)))
                S[i].cnt=S[j].cnt+1, S[i].mx=max(S[j].mx, i-j), S[i].cut=j;
        }
    }

    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 2 ms 248 KB Output is correct
2 Correct 3 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 3 ms 636 KB Output is correct
5 Correct 4 ms 636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 636 KB Output is correct
2 Correct 2 ms 636 KB Output is correct
3 Correct 3 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 672 KB Output is correct
2 Correct 3 ms 672 KB Output is correct
3 Correct 2 ms 672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 740 KB Output is correct
2 Correct 36 ms 740 KB Output is correct
3 Correct 25 ms 868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 868 KB Output is correct
2 Correct 18 ms 868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2584 ms 2232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2570 ms 2332 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2592 ms 15260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2596 ms 20124 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2582 ms 20252 KB Time limit exceeded
2 Halted 0 ms 0 KB -