제출 #512492

#제출 시각아이디문제언어결과실행 시간메모리
512492AdamGS말 (IOI15_horses)C++17
17 / 100
54 ms21128 KiB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e5+7;
const ll MOD=1e9+7;
ll X[LIM], Y[LIM], tr[4*LIM], N=1, n;
ll cnt(int l, int r) {
	if(r<l) return 1;
	l+=N; r+=N;
	ll ans=tr[l];
	if(l!=r) ans=(ans*tr[r])%MOD;
	while(l/2!=r/2) {
		if(l%2==0) ans=(ans*tr[l+1])%MOD;
		if(r%2==1) ans=(ans*tr[r-1])%MOD;
		l/=2; r/=2;
	}
	return ans;
}
ll solve() {
	ll p=1, k=n;
	while(p<MOD && k>0) {
		--k;
		p*=X[k];
	}
	if(p>=MOD) ++k;
	p=1;
	ll ans=0, x=cnt(0, k-1);
	while(k<n) {
		p*=X[k];
		ans=max(ans, p*Y[k]);
		++k;
	}
	ans%=MOD;
	ans=(ans*x)%MOD;
	return ans;
}
int init(int D, int A[], int B[]) {
	n=D;
	while(N<n) N*=2;
	rep(i, 2*N) tr[i]=1;
	rep(i, n) {
		X[i]=A[i];
		Y[i]=B[i];
		tr[N+i]=X[i];
	}
	for(int i=N-1; i>=0; --i) tr[i]=(tr[2*i]*tr[2*i+1])%MOD;
	return solve();
}

int updateX(int pos, int val) {	
	X[pos]=val;
	pos+=N;
	tr[pos]=val;
	while(pos) {
		tr[pos]=(tr[2*pos]*tr[2*pos+1])%MOD;
		pos/=2;
	}
	return solve();
}

int updateY(int pos, int val) {
	Y[pos]=val;
	return solve();
}

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

horses.cpp: In function 'll cnt(int, int)':
horses.cpp:16:3: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   16 |  l+=N; r+=N;
      |  ~^~~
horses.cpp:16:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   16 |  l+=N; r+=N;
      |        ~^~~
horses.cpp: In function 'll solve()':
horses.cpp:34:22: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   34 |  ll ans=0, x=cnt(0, k-1);
      |                     ~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:53:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   53 |  for(int i=N-1; i>=0; --i) tr[i]=(tr[2*i]*tr[2*i+1])%MOD;
      |            ~^~
horses.cpp:54:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   54 |  return solve();
      |         ~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:59:5: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   59 |  pos+=N;
      |  ~~~^~~
horses.cpp:65:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   65 |  return solve();
      |         ~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:70:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   70 |  return solve();
      |         ~~~~~^~
#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...