Submission #532464

# Submission time Handle Problem Language Result Execution time Memory
532464 2022-03-03T00:23:32 Z definitelynotmee Teams (CEOI11_tea) C++
0 / 100
297 ms 35728 KB
#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

tea.cpp: In function 'int main()':
tea.cpp:49:13: warning: unused variable 'timer' [-Wunused-variable]
   49 |         int timer = 0;
      |             ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 0 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
2 Incorrect 2 ms 460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 2964 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 210 ms 27112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 276 ms 35728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 297 ms 33520 KB Output isn't correct
2 Halted 0 ms 0 KB -