Submission #600343

#TimeUsernameProblemLanguageResultExecution timeMemory
600343SOCIOPATEA Difficult(y) Choice (BOI21_books)C++17
Compilation error
0 ms0 KiB
#ifdef LOCAL
    #define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>
#include "books.h"

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define pll pair<ll, ll>
#define pii pair<int, int>
#define pdd pair<ld, ld>
#define ff first
#define ss second
#define all(v) v.begin(),v.end()

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update> ordset;

#pragma GCC optimize("-O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-Os")

ll INF = 1e18;
ll mod = 1e9 + 7;

mt19937 gen(time(0));

void solve(int n, int k, ll a, int s){
    vector<pll> b;
    for(int i = 0; i < k; i++){
        b.push_back([skim(i + 1), (ll)i + 1});
    }
    int l = k - 1, r = n - 1, ans = -1;
    while(l <= r){
        int m = (l + r) / 2;
        ll u = skim(m + 1);
        if(u >= a){
            ans = m;
            r = m - 1;
        } else l = m + 1;
    }
    for(int i = max(k, ans - k); i <= ans; i++) b.push_back({skim(i + 1), (ll)i + 1});
    n = (int)b.size();
    for(int mask = 0; mask < (1 << n); mask){
        ll sum = 0;
        for(int i = 0; i < n; i++) if(mask & (1 << i)) sum += b[i].ff;
        if(sum >= a && sum <= 2ll*a){
            vector<int> res;
            for(int i = 0; i < n; i++) if(mask & (1 << i)) res.push_back(b[i].ss);
            answer(res);
        }
    }
    impossible();
}

//int main() {
//    ios_base::sync_with_stdio(0);
//    cin.tie(0);
//    #ifdef LOCAL
//        freopen("input.txt", "r", stdin);
//    #endif
//	int tt;
//    cin >> tt;
//	tt = 1;
//	while (tt--) {
//		solve();
//		#ifdef LOCAL
//            cout << "__________________________________" << endl;
//		#endif
//	}
//	#ifdef LOCAL
//        cout << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << "sec" << '\n';
//	#endif
//	return 0;
//}

Compilation message (stderr)

books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:44:35: error: expected identifier before '(' token
   44 |         b.push_back([skim(i + 1), (ll)i + 1});
      |                                   ^
books.cpp:44:44: error: expected ']' before '}' token
   44 |         b.push_back([skim(i + 1), (ll)i + 1});
      |                                            ^
      |                                            ]
books.cpp: In lambda function:
books.cpp:44:44: error: expected '{' before '}' token
books.cpp: In function 'void solve(int, int, ll, int)':
books.cpp:44:44: error: expected ')' before '}' token
   44 |         b.push_back([skim(i + 1), (ll)i + 1});
      |                    ~                       ^
      |                                            )
books.cpp:44:45: error: expected primary-expression before ')' token
   44 |         b.push_back([skim(i + 1), (ll)i + 1});
      |                                             ^
books.cpp: At global scope:
books.cpp:46:13: error: 'k' was not declared in this scope
   46 |     int l = k - 1, r = n - 1, ans = -1;
      |             ^
books.cpp:47:5: error: expected unqualified-id before 'while'
   47 |     while(l <= r){
      |     ^~~~~
books.cpp:55:5: error: expected unqualified-id before 'for'
   55 |     for(int i = max(k, ans - k); i <= ans; i++) b.push_back({skim(i + 1), (ll)i + 1});
      |     ^~~
books.cpp:55:34: error: 'i' does not name a type
   55 |     for(int i = max(k, ans - k); i <= ans; i++) b.push_back({skim(i + 1), (ll)i + 1});
      |                                  ^
books.cpp:55:44: error: 'i' does not name a type
   55 |     for(int i = max(k, ans - k); i <= ans; i++) b.push_back({skim(i + 1), (ll)i + 1});
      |                                            ^
books.cpp:55:85: error: expected unqualified-id before ')' token
   55 |     for(int i = max(k, ans - k); i <= ans; i++) b.push_back({skim(i + 1), (ll)i + 1});
      |                                                                                     ^
books.cpp:56:5: error: 'n' does not name a type
   56 |     n = (int)b.size();
      |     ^
books.cpp:57:5: error: expected unqualified-id before 'for'
   57 |     for(int mask = 0; mask < (1 << n); mask){
      |     ^~~
books.cpp:57:23: error: 'mask' does not name a type
   57 |     for(int mask = 0; mask < (1 << n); mask){
      |                       ^~~~
books.cpp:57:40: error: 'mask' does not name a type
   57 |     for(int mask = 0; mask < (1 << n); mask){
      |                                        ^~~~
books.cpp:66:17: error: expected constructor, destructor, or type conversion before ';' token
   66 |     impossible();
      |                 ^
books.cpp:67:1: error: expected declaration before '}' token
   67 | }
      | ^