Submission #62312

#TimeUsernameProblemLanguageResultExecution timeMemory
62312tugushka말 (IOI15_horses)C++14
100 / 100
525 ms46780 KiB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;

#define mod 1000000007
#define L(x) ((x)<<1)
#define R(x) (((x)<<1)|1)

struct Node{
	double sumx, y, max_val;
	int res, modx, xx, yy;
} tree[1<<21];

int n;
void update(int l, int r, int x, int pos, int dx, int dy){
	if( r < pos || pos < l) return;
	if( l == pos && l == r ){
		if( dx ) tree[x].sumx = log10(dx), tree[x].xx = dx;
		if( dy ) tree[x].y = log10(dy), tree[x].yy = dy;
		tree[x].max_val = tree[x].sumx + tree[x].y;
		tree[x].res = 1LL * tree[x].xx * tree[x].yy % mod;
		tree[x].modx = tree[x].xx;
		return;
	}
	
	int mid = (l+r)>>1;
	update( l, mid, L(x), pos, dx, dy );
	update( mid+1, r, R(x), pos, dx, dy );
	
	tree[x].sumx = tree[L(x)].sumx + tree[R(x)].sumx;
	tree[x].modx = 1LL * tree[L(x)].modx * tree[R(x)].modx % mod;
	if( tree[L(x)].max_val < tree[R(x)].max_val + tree[L(x)].sumx ){
		tree[x].max_val = tree[R(x)].max_val + tree[L(x)].sumx;
		tree[x].res = 1LL * tree[R(x)].res * tree[L(x)].modx % mod;
	}
	else{
		tree[x].max_val = tree[L(x)].max_val;
		tree[x].res = tree[L(x)].res;
	}
}

int init(int N, int X[], int Y[]) {
	n = N;
	for(int i = 0 ; i < n ; i++) update( 0, n-1, 1, i, X[i], Y[i] );
	return tree[1].res;
}

int updateX(int pos, int val) {	
	update(0, n-1, 1, pos, val, 0);
	return tree[1].res;
}

int updateY(int pos, int val) {
	update(0, n-1, 1, pos, 0, val);
	return tree[1].res;
}

Compilation message (stderr)

horses.cpp: In function 'void update(int, int, int, int, int, int)':
horses.cpp:21:47: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   tree[x].res = 1LL * tree[x].xx * tree[x].yy % mod;
                                               ^
horses.cpp:31:57: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  tree[x].modx = 1LL * tree[L(x)].modx * tree[R(x)].modx % mod;
                                                         ^
horses.cpp:34:56: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   tree[x].res = 1LL * tree[R(x)].res * tree[L(x)].modx % mod;
                                                        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...