제출 #982201

#제출 시각아이디문제언어결과실행 시간메모리
982201Amaarsaa말 (IOI15_horses)C++14
17 / 100
354 ms54512 KiB
#include<bits/stdc++.h>
#include "horses.h"

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
struct node{
	ll v, x, y; double dx, dy, dv;
}t[4 * 500005];

ll n;
node merge(node a, node b) {
	node res;
	b.dx += a.dx;
	b.dv += a.dx;
	if ( a.dv > b.dv) res.v = a.v, res.dv = a.dv;
	else res.v = (a.x * b.v)% mod, res.dv = b.dv;
	res.x = a.x * b.x % mod;
	res.dx = b.dx;
	return res;
}

node upd(ll p, ll lo, ll hi, ll ind, ll x, ll y) {
	if (lo > ind || ind > hi) return t[p];
	if (lo == hi) {
		node& nd = t[p];
		if ( x ) nd.dx = log(x), nd.x =x;
		if ( y ) nd.dy = log(y), nd.y =y;
		nd.v = (nd.x * nd.y) % mod;
		nd.dv = nd.dx + nd.dy;
		return nd;
	}
	int mid = (lo +hi)/2;
	return t[p] = merge(upd(2 * p, lo, mid, ind, x, y), upd(2 * p + 1, mid + 1, hi, ind, x, y));
}

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

int updateX(int pos, int val) {	
	upd(1, 0, n - 1, pos, val, 0);
	return t[1].v;
}

int updateY(int pos, int val) {
	upd(1, 0, n - 1, pos, 0, val);
	return t[1].x;
}

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'node upd(ll, ll, ll, ll, ll, ll)':
horses.cpp:33:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   33 |  int mid = (lo +hi)/2;
      |            ~~~~~~~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:40:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   40 |  return t[1].v;
      |         ~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:45:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   45 |  return t[1].v;
      |         ~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:50:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   50 |  return t[1].x;
      |         ~~~~~^
#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...