Submission #1354050

#TimeUsernameProblemLanguageResultExecution timeMemory
1354050gvancakA Difficult(y) Choice (BOI21_books)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#include "books.h"

using namespace std;

ll a[100005];
void solve(int N, int K, long long A, int S) {
    // TODO implement this function
    ll k=K;
    ll x=A;
    
    ll l=1,r=N;
    while (l<r){
    	int mid=(l+r)/2;
    	int y=skim(mid); a[mid]=y;
    	if (y<x) l=mid+1; else r=mid;
	}
//	cout<<l<<endl;
	vector <ll> ans;
	ans.clear();
	ll sum=0;
	ll b[2*k+5];
	for (int i=1; i<=2*k; i++) b[i]=0;
	sum=0;
	for (int i=1; i<=k; i++){
		if (a[i]==0) {
			x=skim(i); a[i]=x;
		}
		sum+=x;
		b[i]=i;
	}//cout<<"a"<<endl;
	if (sum>2*A){
		impossible(); return;
	}
	else
	if (sum>=A){
		for (int i=1; i<=k; i++) ans.pb(i);
		answer(ans); return;
	}
		if (l>k){
		
	if (a[l]==0){
		x=skim(l); a[l]=x;
	}
	
	sum-=a[b[k]]; sum+=a[l];
	if (sum>=A && sum<=2*A){
		for (int i=1; i<k; i++) ans.pb(i);
		ans.pb(l);
		answer(ans);
	}
	
	}
	sum=0;
	for (int i=1; i<=k; i++) sum+=a[b[i]];
	
	ll sz=k;
	for (int i=l-k; i<l; i++){
		if (i<=k) continue;
		sz++; b[sz]=i; if (a[i]==0){
			x=skim(i); a[i]=x;
		}
	}
	ll ind=-1;
	for (int i=k+1; i<=sz; i++){
		
		sum-=a[b[i-k]]; sum+=a[b[i]];
		if (sum>=A) {
			ind=i-k+1; break;
		}
	}
	//cout<<sum<<endl;
	if (ind==-1 || sum>2*A){
		impossible(); return ;
	}
	
	ans.clear();
	for (int i=ind; i<ind+k; i++){
		ans.pb(b[i]);
	}
	answer(ans);
	
	

}
/*
15 3 42 8
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21*/

/*
15 3 42 8
1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351
*/

Compilation message (stderr)

books.cpp:10:1: error: 'll' does not name a type
   10 | ll a[100005];
      | ^~
books.cpp: In function 'void solve(int, int, long long int, int)':
books.cpp:13:5: error: 'll' was not declared in this scope
   13 |     ll k=K;
      |     ^~
books.cpp:14:7: error: expected ';' before 'x'
   14 |     ll x=A;
      |       ^~
      |       ;
books.cpp:16:7: error: expected ';' before 'l'
   16 |     ll l=1,r=N;
      |       ^~
      |       ;
books.cpp:17:14: error: 'r' was not declared in this scope
   17 |     while (l<r){
      |              ^
books.cpp:17:12: error: 'l' was not declared in this scope
   17 |     while (l<r){
      |            ^
books.cpp:19:26: error: 'a' was not declared in this scope
   19 |         int y=skim(mid); a[mid]=y;
      |                          ^
books.cpp:20:15: error: 'x' was not declared in this scope
   20 |         if (y<x) l=mid+1; else r=mid;
      |               ^
books.cpp:23:19: error: template argument 2 is invalid
   23 |         vector <ll> ans;
      |                   ^
books.cpp:24:13: error: request for member 'clear' in 'ans', which is of non-class type 'int'
   24 |         ans.clear();
      |             ^~~~~
books.cpp:25:11: error: expected ';' before 'sum'
   25 |         ll sum=0;
      |           ^~~~
      |           ;
books.cpp:26:11: error: expected ';' before 'b'
   26 |         ll b[2*k+5];
      |           ^~
      |           ;
books.cpp:27:28: error: 'k' was not declared in this scope
   27 |         for (int i=1; i<=2*k; i++) b[i]=0;
      |                            ^
books.cpp:27:36: error: 'b' was not declared in this scope
   27 |         for (int i=1; i<=2*k; i++) b[i]=0;
      |                                    ^
books.cpp:28:9: error: 'sum' was not declared in this scope
   28 |         sum=0;
      |         ^~~
books.cpp:29:26: error: 'k' was not declared in this scope
   29 |         for (int i=1; i<=k; i++){
      |                          ^
books.cpp:30:21: error: 'a' was not declared in this scope
   30 |                 if (a[i]==0) {
      |                     ^
books.cpp:31:25: error: 'x' was not declared in this scope
   31 |                         x=skim(i); a[i]=x;
      |                         ^
books.cpp:33:22: error: 'x' was not declared in this scope
   33 |                 sum+=x;
      |                      ^
books.cpp:34:17: error: 'b' was not declared in this scope
   34 |                 b[i]=i;
      |                 ^
books.cpp:41:34: error: 'k' was not declared in this scope
   41 |                 for (int i=1; i<=k; i++) ans.pb(i);
      |                                  ^
books.cpp:4:12: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
    4 | #define pb push_back
      |            ^~~~~~~~~
books.cpp:41:46: note: in expansion of macro 'pb'
   41 |                 for (int i=1; i<=k; i++) ans.pb(i);
      |                                              ^~
books.cpp:42:24: error: could not convert 'ans' from 'int' to 'std::vector<int>'
   42 |                 answer(ans); return;
      |                        ^~~
      |                        |
      |                        int
books.cpp:44:21: error: 'l' was not declared in this scope
   44 |                 if (l>k){
      |                     ^
books.cpp:44:23: error: 'k' was not declared in this scope
   44 |                 if (l>k){
      |                       ^
books.cpp:46:13: error: 'a' was not declared in this scope
   46 |         if (a[l]==0){
      |             ^
books.cpp:47:17: error: 'x' was not declared in this scope
   47 |                 x=skim(l); a[l]=x;
      |                 ^
books.cpp:50:14: error: 'a' was not declared in this scope
   50 |         sum-=a[b[k]]; sum+=a[l];
      |              ^
books.cpp:50:16: error: 'b' was not declared in this scope
   50 |         sum-=a[b[k]]; sum+=a[l];
      |                ^
books.cpp:4:12: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
    4 | #define pb push_back
      |            ^~~~~~~~~
books.cpp:52:45: note: in expansion of macro 'pb'
   52 |                 for (int i=1; i<k; i++) ans.pb(i);
      |                                             ^~
books.cpp:4:12: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
    4 | #define pb push_back
      |            ^~~~~~~~~
books.cpp:53:21: note: in expansion of macro 'pb'
   53 |                 ans.pb(l);
      |                     ^~
books.cpp:54:24: error: could not convert 'ans' from 'int' to 'std::vector<int>'
   54 |                 answer(ans);
      |                        ^~~
      |                        |
      |                        int
books.cpp:59:26: error: 'k' was not declared in this scope
   59 |         for (int i=1; i<=k; i++) sum+=a[b[i]];
      |                          ^
books.cpp:59:39: error: 'a' was not declared in this scope
   59 |         for (int i=1; i<=k; i++) sum+=a[b[i]];
      |                                       ^
books.cpp:59:41: error: 'b' was not declared in this scope
   59 |         for (int i=1; i<=k; i++) sum+=a[b[i]];
      |                                         ^
books.cpp:61:11: error: expected ';' before 'sz'
   61 |         ll sz=k;
      |           ^~~
      |           ;
books.cpp:62:20: error: 'l' was not declared in this scope
   62 |         for (int i=l-k; i<l; i++){
      |                    ^
books.cpp:62:22: error: 'k' was not declared in this scope
   62 |         for (int i=l-k; i<l; i++){
      |                      ^
books.cpp:64:17: error: 'sz' was not declared in this scope; did you mean 's'?
   64 |                 sz++; b[sz]=i; if (a[i]==0){
      |                 ^~
      |                 s
books.cpp:64:23: error: 'b' was not declared in this scope
   64 |                 sz++; b[sz]=i; if (a[i]==0){
      |                       ^
books.cpp:64:36: error: 'a' was not declared in this scope
   64 |                 sz++; b[sz]=i; if (a[i]==0){
      |                                    ^
books.cpp:65:25: error: 'x' was not declared in this scope
   65 |                         x=skim(i); a[i]=x;
      |                         ^
books.cpp:68:11: error: expected ';' before 'ind'
   68 |         ll ind=-1;
      |           ^~~~
      |           ;
books.cpp:69:20: error: 'k' was not declared in this scope
   69 |         for (int i=k+1; i<=sz; i++){
      |                    ^
books.cpp:69:28: error: 'sz' was not declared in this scope; did you mean 's'?
   69 |         for (int i=k+1; i<=sz; i++){
      |                            ^~
      |                            s
books.cpp:71:22: error: 'a' was not declared in this scope
   71 |                 sum-=a[b[i-k]]; sum+=a[b[i]];
      |                      ^
books.cpp:71:24: error: 'b' was not declared in this scope
   71 |                 sum-=a[b[i-k]]; sum+=a[b[i]];
      |                        ^
books.cpp:73:25: error: 'ind' was not declared in this scope; did you mean 'int'?
   73 |                         ind=i-k+1; break;
      |                         ^~~
      |                         int
books.cpp:77:13: error: 'ind' was not declared in this scope; did you mean 'int'?
   77 |         if (ind==-1 || sum>2*A){
      |             ^~~
      |             int
books.cpp:81:13: error: request for member 'clear' in 'ans', which is of non-class type 'int'
   81 |         ans.clear();
      |             ^~~~~
books.cpp:82:20: error: 'ind' was not declared in this scope; did you mean 'int'?
   82 |         for (int i=ind; i<ind+k; i++){
      |                    ^~~
      |                    int
books.cpp:82:31: error: 'k' was not declared in this scope
   82 |         for (int i=ind; i<ind+k; i++){
      |                               ^
books.cpp:4:12: error: request for member 'push_back' in 'ans', which is of non-class type 'int'
    4 | #define pb push_back
      |            ^~~~~~~~~
books.cpp:83:21: note: in expansion of macro 'pb'
   83 |                 ans.pb(b[i]);
      |                     ^~
books.cpp:83:24: error: 'b' was not declared in this scope
   83 |                 ans.pb(b[i]);
      |                        ^
books.cpp:85:16: error: could not convert 'ans' from 'int' to 'std::vector<int>'
   85 |         answer(ans);
      |                ^~~
      |                |
      |                int