Submission #986965

# Submission time Handle Problem Language Result Execution time Memory
986965 2024-05-21T16:09:51 Z 876pol Cookies (JOI23_cookies) C++17
Compilation error
0 ms 0 KB
#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define dbg(...)
#define STRUCT_DBG(...)
#else
#include "lib/debug.h"
#endif

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
template <class T>
using vec = vector<T>;
using vll = vector<ll>;
using vpll = vector<pair<ll, ll>>;
using vvll = vector<vector<ll>>;
using vvpll = vector<vector<pair<ll, ll>>>;
template <class T>
using indexed_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define FOR(i, s, e) for (ll i = (ll)s; i < (ll)e; i++)
#define CFOR(i, s, e) for (ll i = (ll)s; i <= (ll)e; i++)
#define RFOR(i, e, s) for (ll i = (ll)e - 1; i >= (ll)s; i--)
#define TRAV(a, c) for (const auto &a : c)
#define all(x) x.begin(), x.end()

#define MOD 1000000007
// #define MOD 998244353

#define FASTIO
#define PRECISION
// #define FILE "file"

#define SINGLE
// #define MULTIPLE
// #define GOOGLE

void solve() {
    ll n;
    cin >> n;
    vll a(n);
    FOR(i, 0, n) cin >> a[i];
    ll m;
    cin >> m;
    vll b(m);
    FOR(i, 0, m) cin >> b[i];
    bool st1 = true, st2 = (m == 1);
    FOR(i, 0, n) st1 &= (a[i] == 1);
    if (st1) {
        vll dp(n + 1, INT_MAX), from(n + 1, -1);
        dp[0] = 0;
        FOR(i, 0, n) {
            if (dp[i] == INT_MAX) continue;
            TRAV(e, b) {
                if (i + e <= n && dp[i] + 1 < dp[i + e]) {
                    dp[i + e] = dp[i] + 1;
                    from[i + e] = i;
                }
            }
        }
        ll ind = 1, curr = n;
        if (dp[curr] == INT_MAX) {
            cout << "-1\n";
            return;
        }
        cout << dp[curr] << "\n";
        while (curr != 0) {
            cout << curr - from[curr] << " ";
            FOR(i, 0, curr - from[curr]) {
                cout << ind++ << " ";
            }
            cout << "\n";
            curr = from[curr];
        }
    } else if (st2) {
    } else {
    }
}

int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#endif
#ifdef PRECISION
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
#endif
#ifdef FILE
    freopen((FILE + string(".in")).c_str(), "r", stdin);
    freopen((FILE + string(".out")).c_str(), "w", stdout);
#endif
#ifdef SINGLE
    solve();
#endif
#ifdef MULTIPLE
    ll t;
    cin >> t;
    for (ll i = 1; i <= t; i++) {
        solve();
    }
#endif
#ifdef GOOGLE
    ll t;
    cin >> t;
    for (ll i = 1; i <= t; i++) {
        cout << "Case #" << i << ": ";
        solve();
    }
#endif
}
-

Compilation message

cookies.cpp:121:1: error: expected unqualified-id before '-' token
  121 | -
      | ^