Submission #1138128

#TimeUsernameProblemLanguageResultExecution timeMemory
1138128Ekber_EkberHorses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include "horses.h"
#include <bits/stdc++.h>
#define ll int128_t
#define itn int
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define count1 __builtin_popcount
#define all(v) v.begin(), v.end()
using namespace std;

struct point{
	ll ans, sum;
};

constexpr ll MAX = 5e+5 + 3, INF = 2e+9, MOD = 1e+9 + 7, K = log2(MAX);
ll n;
vector <ll> a, b;
vector <point> t(4 * MAX);

void build(ll v, ll tl, ll tr) {
	if (tl == tr) {
		t[v].ans = (a[tl] * b[tl]) % MOD;
		t[v].sum = a[tl];
		return;
	}
	ll tm = (tl + tr) / 2;
	build(v*2, tl, tm);
	build(v*2+1, tm+1, tr);
	t[v].sum = (t[v*2].sum * t[v*2+1].sum) % MOD;
	t[v].ans = max(t[v*2].ans, (t[v*2].sum * t[v*2+1].ans) % MOD);
}

point find(ll v, ll tl, ll tr, ll l, ll r) {
	if (l > r) return {INF, INF};
	if (tl == l && tr == r) return t[v];
	ll tm = (tl + tr) / 2;
	point res1 = find(v*2, tl, tm, l, min(r, tm));
	point res2 = find(v*2+1, tm+1, tr, max(l, tm+1), r);
	point res;
	res.sum = (res1.sum * res2.sum) % MOD;
	res.ans = max(res1.ans, (res1.sum * res2.ans) % MOD);
	return res;
}

void updatex(ll v, ll tl, ll tr, ll i, ll x) {
	if (tl == tr) {
		t[v].ans = (x * b[tl]) % MOD;
		t[v].sum = x;
		a[tl] = x;
		return;
	}
	ll tm = (tl + tr) / 2;
	if (i <= tm) {
		updatex(v*2, tl, tm, i, x);
	}
	else {
		updatex(v*2+1, tm+1, tr, i, x);
	}
	t[v].sum = (t[v*2].sum * t[v*2+1].sum) % MOD;
	t[v].ans = max(t[v*2].ans, (t[v*2].sum * t[v*2+1].ans) % MOD);
}

void updatey(ll v, ll tl, ll tr, ll i, ll y) {
	if (tl == tr) {
		t[v].ans = (a[tl] * y) % MOD;
		b[tl] = y;
		return;
	}
	ll tm = (tl + tr) / 2;
	if (i <= tm) {
		updatey(v*2, tl, tm, i, y);
	}
	else {
		updatey(v*2+1, tm+1, tr, i, y);
	}
	t[v].sum = (t[v*2].sum * t[v*2+1].sum) % MOD;
	t[v].ans = max(t[v*2].ans, (t[v*2].sum * t[v*2+1].ans) % MOD);
}

int init(int N, int X[], int Y[]) {
	cin >> N;
	for (int i=0; i < N; i++) {
		cin >> X[i];
	}
	for (int i=0; i < N; i++) {
		cin >> Y[i];
	}
	n = (ll)N;
	for (int i=0; i < N; i++) {
		a.pb(X[i]);
		b.pb(Y[i]);
	}
	build(1, 0, n-1);
	return 0;
}

int updateX(int pos, int val) {
	ll i = (ll)pos, x = (ll)val;
	updatex(1, 0, n-1, i, x);
	return t[1].ans;
}

int updateY(int pos, int val) {
	ll i = (ll)pos, y = (ll)val;
	updatey(1, 0, n-1, i, y);
	return t[1].ans;
}

Compilation message (stderr)

horses.cpp:3:12: error: 'int128_t' does not name a type; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:19:9: note: in expansion of macro 'll'
   19 |         ll ans, sum;
      |         ^~
horses.cpp:3:12: error: 'int128_t' does not name a type; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:22:11: note: in expansion of macro 'll'
   22 | constexpr ll MAX = 5e+5 + 3, INF = 2e+9, MOD = 1e+9 + 7, K = log2(MAX);
      |           ^~
horses.cpp:3:12: error: 'int128_t' does not name a type; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:23:1: note: in expansion of macro 'll'
   23 | ll n;
      | ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:24:9: note: in expansion of macro 'll'
   24 | vector <ll> a, b;
      |         ^~
horses.cpp:24:11: error: template argument 1 is invalid
   24 | vector <ll> a, b;
      |           ^
horses.cpp:24:11: error: template argument 2 is invalid
horses.cpp:25:22: error: 'MAX' was not declared in this scope
   25 | vector <point> t(4 * MAX);
      |                      ^~~
horses.cpp:27:6: error: variable or field 'build' declared void
   27 | void build(ll v, ll tl, ll tr) {
      |      ^~~~~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:27:12: note: in expansion of macro 'll'
   27 | void build(ll v, ll tl, ll tr) {
      |            ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:27:18: note: in expansion of macro 'll'
   27 | void build(ll v, ll tl, ll tr) {
      |                  ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:27:25: note: in expansion of macro 'll'
   27 | void build(ll v, ll tl, ll tr) {
      |                         ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:40:12: note: in expansion of macro 'll'
   40 | point find(ll v, ll tl, ll tr, ll l, ll r) {
      |            ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:40:18: note: in expansion of macro 'll'
   40 | point find(ll v, ll tl, ll tr, ll l, ll r) {
      |                  ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:40:25: note: in expansion of macro 'll'
   40 | point find(ll v, ll tl, ll tr, ll l, ll r) {
      |                         ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:40:32: note: in expansion of macro 'll'
   40 | point find(ll v, ll tl, ll tr, ll l, ll r) {
      |                                ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:40:38: note: in expansion of macro 'll'
   40 | point find(ll v, ll tl, ll tr, ll l, ll r) {
      |                                      ^~
horses.cpp:40:44: error: expected ',' or ';' before '{' token
   40 | point find(ll v, ll tl, ll tr, ll l, ll r) {
      |                                            ^
horses.cpp:52:6: error: variable or field 'updatex' declared void
   52 | void updatex(ll v, ll tl, ll tr, ll i, ll x) {
      |      ^~~~~~~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:52:14: note: in expansion of macro 'll'
   52 | void updatex(ll v, ll tl, ll tr, ll i, ll x) {
      |              ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:52:20: note: in expansion of macro 'll'
   52 | void updatex(ll v, ll tl, ll tr, ll i, ll x) {
      |                    ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:52:27: note: in expansion of macro 'll'
   52 | void updatex(ll v, ll tl, ll tr, ll i, ll x) {
      |                           ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:52:34: note: in expansion of macro 'll'
   52 | void updatex(ll v, ll tl, ll tr, ll i, ll x) {
      |                                  ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:52:40: note: in expansion of macro 'll'
   52 | void updatex(ll v, ll tl, ll tr, ll i, ll x) {
      |                                        ^~
horses.cpp:70:6: error: variable or field 'updatey' declared void
   70 | void updatey(ll v, ll tl, ll tr, ll i, ll y) {
      |      ^~~~~~~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:70:14: note: in expansion of macro 'll'
   70 | void updatey(ll v, ll tl, ll tr, ll i, ll y) {
      |              ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:70:20: note: in expansion of macro 'll'
   70 | void updatey(ll v, ll tl, ll tr, ll i, ll y) {
      |                    ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:70:27: note: in expansion of macro 'll'
   70 | void updatey(ll v, ll tl, ll tr, ll i, ll y) {
      |                           ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:70:34: note: in expansion of macro 'll'
   70 | void updatey(ll v, ll tl, ll tr, ll i, ll y) {
      |                                  ^~
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:70:40: note: in expansion of macro 'll'
   70 | void updatey(ll v, ll tl, ll tr, ll i, ll y) {
      |                                        ^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:95:9: error: 'n' was not declared in this scope
   95 |         n = (ll)N;
      |         ^
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:95:14: note: in expansion of macro 'll'
   95 |         n = (ll)N;
      |              ^~
horses.cpp:8:12: error: request for member 'push_back' in 'a', which is of non-class type 'int'
    8 | #define pb push_back
      |            ^~~~~~~~~
horses.cpp:97:19: note: in expansion of macro 'pb'
   97 |                 a.pb(X[i]);
      |                   ^~
horses.cpp:8:12: error: request for member 'push_back' in 'b', which is of non-class type 'int'
    8 | #define pb push_back
      |            ^~~~~~~~~
horses.cpp:98:19: note: in expansion of macro 'pb'
   98 |                 b.pb(Y[i]);
      |                   ^~
horses.cpp:100:9: error: 'build' was not declared in this scope
  100 |         build(1, 0, n-1);
      |         ^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:105:9: note: in expansion of macro 'll'
  105 |         ll i = (ll)pos, x = (ll)val;
      |         ^~
horses.cpp:106:23: error: 'n' was not declared in this scope; did you mean 'yn'?
  106 |         updatex(1, 0, n-1, i, x);
      |                       ^
      |                       yn
horses.cpp:106:28: error: 'i' was not declared in this scope
  106 |         updatex(1, 0, n-1, i, x);
      |                            ^
horses.cpp:106:31: error: 'x' was not declared in this scope
  106 |         updatex(1, 0, n-1, i, x);
      |                               ^
horses.cpp:106:9: error: 'updatex' was not declared in this scope; did you mean 'updateX'?
  106 |         updatex(1, 0, n-1, i, x);
      |         ^~~~~~~
      |         updateX
horses.cpp:107:21: error: '__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type' {aka 'struct point'} has no member named 'ans'
  107 |         return t[1].ans;
      |                     ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:3:12: error: 'int128_t' was not declared in this scope; did you mean 'int8_t'?
    3 | #define ll int128_t
      |            ^~~~~~~~
horses.cpp:111:9: note: in expansion of macro 'll'
  111 |         ll i = (ll)pos, y = (ll)val;
      |         ^~
horses.cpp:112:23: error: 'n' was not declared in this scope; did you mean 'yn'?
  112 |         updatey(1, 0, n-1, i, y);
      |                       ^
      |                       yn
horses.cpp:112:28: error: 'i' was not declared in this scope
  112 |         updatey(1, 0, n-1, i, y);
      |                            ^
horses.cpp:112:31: error: 'y' was not declared in this scope; did you mean 'yn'?
  112 |         updatey(1, 0, n-1, i, y);
      |                               ^
      |                               yn
horses.cpp:112:9: error: 'updatey' was not declared in this scope; did you mean 'updateY'?
  112 |         updatey(1, 0, n-1, i, y);
      |         ^~~~~~~
      |         updateY
horses.cpp:113:21: error: '__gnu_cxx::__alloc_traits<std::allocator<point>, point>::value_type' {aka 'struct point'} has no member named 'ans'
  113 |         return t[1].ans;
      |                     ^~~