Submission #839146

# Submission time Handle Problem Language Result Execution time Memory
839146 2023-08-28T19:50:32 Z emkow Teams (CEOI11_tea) C++14
80 / 100
241 ms 78652 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#define pb emplace_back
#define ins insert
#define ssize(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pld pair <ld, ld>
#define st first
#define nd second

using namespace std;
using ll = int_fast64_t;
// using lll = __int128_t;
using ld = long double;
const int oo = 1e9 + 7;
const int mod = 1e9 + 7;

void solve(){
    int n; cin >> n;
    vector <pii> arr(n);
    for(int i = 0; i < n; i ++){
        cin >> arr[i].st;
        arr[i].nd = i;
    }
    sort(all(arr));
    vector <int> ans(n);
    vector <vector<int>> which;
    int counter = -1;
    for(int i = n - 1; i >= 0; i --){
        if(arr[i].st > i + 1){
            pii mini = {oo, oo};
            for(int j = 0; j <= counter; j ++){
                mini = min(mini, {ssize(which[j]), j});
            }
            ans[arr[i].nd] = mini.nd;
            which[mini.nd].pb(arr[i].nd);
            continue;
        }
        counter ++;
        which.push_back({});
        for(int j = i; j >= i - arr[i].st + 1; j --){
            ans[arr[j].nd] = counter;
            which[counter].pb(arr[j].nd);
        }
        i -= arr[i].st - 1;
    }
    cout << counter + 1 << '\n';
    for(int i = 0; i <= counter; i ++){
        cout << ssize(which[i]) << ' ';
        for(auto it: which[i]) cout << it + 1 << ' ';
        cout << '\n';
    }
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int t; t = 1;
    // cin >> t;
    while(t --) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2644 KB Output is correct
2 Correct 15 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 2892 KB Output is correct
2 Correct 14 ms 2516 KB Output is correct
3 Correct 18 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 21372 KB Output is correct
2 Correct 147 ms 21628 KB Output is correct
3 Correct 157 ms 22536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 207 ms 28864 KB Output is correct
2 Correct 241 ms 78652 KB Output is correct
3 Correct 192 ms 28700 KB Output is correct
4 Correct 189 ms 25232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 215 ms 29836 KB Output is correct
2 Correct 154 ms 30832 KB Output is correct
3 Correct 198 ms 27604 KB Output is correct
4 Correct 218 ms 28832 KB Output is correct