Submission #742520

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
7425202023-05-16 11:23:32Dan4LifeHorses (IOI15_horses)C++17
100 / 100
372 ms56176 KiB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mxN = (int)5e5+10;
const int MOD = (int)1e9+7;
struct Data{ double sum, ans; int i; } segTree[2*mxN];
ll n, X[mxN], Y[mxN], segTree2[2*mxN];
Data comb(Data &a, Data &b){
Data c = {a.sum+b.sum,a.ans,a.i};
if(a.ans <= a.sum+b.ans) c.i=b.i;
c.ans = max(a.ans, a.sum+b.ans);
return c;
}
void upd2(int x, ll v, int p=0, int l=0, int r=n-1){
if(l==r){ segTree2[p] = v; return; }
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
if(x<=mid) upd2(x,v,p+1,l,mid);
else upd2(x,v,rp,mid+1,r);
segTree2[p] = (ll)((segTree2[p+1]*segTree2[rp])%MOD);
}
ll query(int i, int j, int p=0, int l=0, int r=n-1){
if(i>r or j<l or i>j) return 1ll;
if(i<=l and r<=j) return segTree2[p];
int mid = (l+r)/2; int rp = p+2*(mid-l+1);
return (query(i,j,p+1,l,mid)*query(i,j,rp,mid+1,r))%MOD;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

horses.cpp:17:49: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   17 | void upd2(int x, ll v, int p=0, int l=0, int r=n-1){
      |                                                ~^~
horses.cpp:25:49: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   25 | ll query(int i, int j, int p=0, int l=0, int r=n-1){
      |                                                ~^~
horses.cpp:32:48: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   32 | void upd(int x, ll v, int p=0, int l=0, int r=n-1){
      |                                               ~^~
horses.cpp: In function 'void upd(int, ll, int, int, int)':
horses.cpp:35:21: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   35 |   X[x] = v; upd2(x,v); return;
      |                     ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:46:39: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   46 |   X[i] = x[i], Y[i] = y[i], upd(i,X[i]);
      |                                       ^
horses.cpp:48:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   48 |  return (query(0,i)*Y[i])%MOD;
      |                   ^
horses.cpp:48:26: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   48 |  return (query(0,i)*Y[i])%MOD;
      |         ~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:52:9: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   52 |  upd(x,v);
      |         ^
horses.cpp:54:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   54 |  return (query(0,i)*Y[i])%MOD;
      |                   ^
horses.cpp:54:26: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   54 |  return (query(0,i)*Y[i])%MOD;
      |         ~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:58:22: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   58 |  Y[x] = v; upd(x,X[x]);
      |                      ^
horses.cpp:60:19: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   60 |  return (query(0,i)*Y[i])%MOD;
      |                   ^
horses.cpp:60:26: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   60 |  return (query(0,i)*Y[i])%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...