Submission #570956

# Submission time Handle Problem Language Result Execution time Memory
570956 2022-05-31T18:14:20 Z beaconmc Secret (JOI14_secret) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
#define double long double
include "secret.h"

using namespace std;

vector<vector<ll>> sus(129);
vector<ll> nums(129);
ll n;

int Secret(ll a, ll b){
	return a+floor(b/2)*2;
}

void sussy(ll a, ll b){
	if (b-a > 2){
		ll mid = (a+b)/2;

		vector<ll> left;
		vector<ll> right;

		left.push_back(nums[mid-1]);

		FORNEG(i, mid-2, a-1){
			left.push_back(Secret(nums[i], left[left.size()-1]));
		}

		right.push_back(nums[mid]);
		FOR(i,mid+1, b){
			right.push_back(Secret(right[right.size()-1], nums[i]));
		}

		reverse(left.begin(), left.end());

		for (auto&i : left){
			sus[mid].push_back(i);
		}

		for (auto&i : right){
			sus[mid].push_back(i);
		}

		sussy(a, mid);
		sussy(mid, b);
	}
}

void Init(int N, int A[]) {
	n = N;
	FOR(i,0,128) nums[i] = 1;

	FOR(i,0,N) nums[i] = A[i];

	sussy(0,128);
}

int Query(int L, int R){
	if (R == L+1){
		return Secret(nums[L], nums[R]);
	}
	ll lo = 0;
	ll hi = 128;

	while (lo<hi){
		ll mid = (lo+hi)/2;


		
		if (L<=mid && mid<R){


			ll size = sus[mid].size()/2;

			return Secret(sus[mid][size - (mid - L)], sus[mid][size+(R-mid)]);
		}

		if (mid<=L && mid<=R){
			lo = mid;
		}
		if (mid >= L && mid >= R){
			hi = mid;
		}
	}
}

// int main(){
// 	int sussy[8] =  {1,4,7,2,5,8,3,6};

// 	Init(8, sussy);




// }







Compilation message

secret.cpp:7:1: error: 'include' does not name a type
    7 | include "secret.h"
      | ^~~~~~~
secret.cpp:11:1: error: 'vector' does not name a type
   11 | vector<vector<ll>> sus(129);
      | ^~~~~~
secret.cpp:12:1: error: 'vector' does not name a type
   12 | vector<ll> nums(129);
      | ^~~~~~
secret.cpp: In function 'void sussy(ll, ll)':
secret.cpp:23:3: error: 'vector' was not declared in this scope; did you mean 'std::vector'?
   23 |   vector<ll> left;
      |   ^~~~~~
      |   std::vector
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from secret.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note: 'std::vector' declared here
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
secret.cpp:23:12: error: expected primary-expression before '>' token
   23 |   vector<ll> left;
      |            ^
secret.cpp:23:14: error: 'left' was not declared in this scope; did you mean 'std::left'?
   23 |   vector<ll> left;
      |              ^~~~
      |              std::left
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from secret.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1006:3: note: 'std::left' declared here
 1006 |   left(ios_base& __base)
      |   ^~~~
secret.cpp:24:12: error: expected primary-expression before '>' token
   24 |   vector<ll> right;
      |            ^
secret.cpp:24:14: error: 'right' was not declared in this scope; did you mean 'std::right'?
   24 |   vector<ll> right;
      |              ^~~~~
      |              std::right
In file included from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from secret.cpp:1:
/usr/include/c++/10/bits/ios_base.h:1014:3: note: 'std::right' declared here
 1014 |   right(ios_base& __base)
      |   ^~~~~
secret.cpp:26:18: error: 'nums' was not declared in this scope
   26 |   left.push_back(nums[mid-1]);
      |                  ^~~~
secret.cpp:37:3: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
   37 |   reverse(left.begin(), left.end());
      |   ^~~~~~~
      |   std::reverse
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from secret.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:1165:5: note: 'std::reverse' declared here
 1165 |     reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
      |     ^~~~~~~
secret.cpp:40:4: error: 'sus' was not declared in this scope; did you mean 'sussy'?
   40 |    sus[mid].push_back(i);
      |    ^~~
      |    sussy
secret.cpp:44:4: error: 'sus' was not declared in this scope; did you mean 'sussy'?
   44 |    sus[mid].push_back(i);
      |    ^~~
      |    sussy
secret.cpp: In function 'void Init(int, int*)':
secret.cpp:54:15: error: 'nums' was not declared in this scope
   54 |  FOR(i,0,128) nums[i] = 1;
      |               ^~~~
secret.cpp:56:13: error: 'nums' was not declared in this scope
   56 |  FOR(i,0,N) nums[i] = A[i];
      |             ^~~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:63:17: error: 'nums' was not declared in this scope
   63 |   return Secret(nums[L], nums[R]);
      |                 ^~~~
secret.cpp:76:14: error: 'sus' was not declared in this scope; did you mean 'sussy'?
   76 |    ll size = sus[mid].size()/2;
      |              ^~~
      |              sussy