Submission #367958

#TimeUsernameProblemLanguageResultExecution timeMemory
367958dennisstarHorses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include "horses.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const ll MOD = 1e9 + 7;

struct {
	ll v, x, y;
	double dv, dx, dy;
}st[1<<20];

void upd(int i, int s, int e, int t, int x, int y) {
	auto &n=st[i];
	if (s==e) {
		if (x) n.x=x, n.dx=log(x);
		if (y) n.y=y, n.dy=log(y);
		n.v=n.x*n.y%MOD;
		n.dv=n.dx+n.dy;
		return ;
	}

	int m=(s+e)/2;
	if (t<=m) upd(i*2, s, m, t, x, y);
	else upd(i*2+1, m+1, e, t, x, y);

	auto &l=st[i*2], &r=st[i*2+1];
	n.x=l.x*r.x%MOD;
	n.dx=l.dx+r.dx;
	tie(n.dv, n.v)=
		max(pair<double, ll>(l.dv, l.v),
		pair<double, ll>(l.dx+r.dv, l.x*r.v%MOD));
}

int init(int n, int *x, int *y) {
	for (int i=0; i<n; i++)
		upd(1, 0, n-1, i, x[i], y[i]);
	return st[1].v;
}

int updateX(int p, int v) {
	upd(1, 0, n-1, p, v, 0);
	return st[1].v;
}

int updateY(int p, int v) {
	upd(1, 0, n-1, p, 0, v);
	return st[1].v;
}

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:39:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   39 |  return st[1].v;
      |         ~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:43:12: error: 'n' was not declared in this scope
   43 |  upd(1, 0, n-1, p, v, 0);
      |            ^
horses.cpp:44:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   44 |  return st[1].v;
      |         ~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:48:12: error: 'n' was not declared in this scope
   48 |  upd(1, 0, n-1, p, 0, v);
      |            ^
horses.cpp:49:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   49 |  return st[1].v;
      |         ~~~~~~^