Submission #408746

#TimeUsernameProblemLanguageResultExecution timeMemory
408746MDarioHorses (IOI15_horses)C++11
0 / 100
77 ms44500 KiB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
const ll mod=1e9+7;
ll n;
ll a[500001], b[500001];
pair<pair<ll, ll>, pair<ll, ll>> st[1000001];
void f(ll xf){
    if(st[xf*2+1].S.F==1){
        st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {1, st[xf*2+1].S.S}};
    }
    else{
        if(st[xf*2].F.S<st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S){
            st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {(st[xf*2].S.F||(st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S*st[xf*2].F.F)>=1e9), st[xf*2+1].S.S}};
        }
        else{
            st[xf]=st[xf*2];
            st[xf].S.S*=st[xf*2+1].S.S*st[xf*2+1].F.F;
        }
    }
    return ;
}
void update(ll xf){
    xf/=2;
    while(xf>0){
        f(xf);
        xf/=2;
    }
    return ;
}
int init(int N, int X[], int Y[]) {
    n=N;
    for(int i=0; i<N; i++){
        a[i]=X[i];
        b[i]=Y[i];
    }
    for(int i=0; i<n; i++){
        st[i+n]={{a[i], b[i]}, {(a[i]*b[i]>=1e9), 1}};
    }
    for(int i=n-1; i>0; i--){
        f(i);
    }
	return (st[1].F.F*st[1].F.S)%mod;
}

int updateX(int pos, int val) {
    a[pos+1]=val;
    st[pos+n]={{a[pos], b[pos]}, {(a[pos]*b[pos]>=1e9), 1}};
    update(pos+n);
	return (st[1].F.F*st[1].F.S)%mod;
}

int updateY(int pos, int val) {
    b[pos+1]=val;
    st[pos+n]={{a[pos], b[pos]}, {(a[pos]*b[pos]>=1e9), 1}};
    update(pos+n);
	return (st[1].F.F*st[1].F.S)%mod;
}

Compilation message (stderr)

horses.cpp: In function 'void f(ll)':
horses.cpp:17:154: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   17 |             st[xf]={{(((st[xf*2].F.F*st[xf*2].S.S)%mod)*st[xf*2+1].F.F)%mod, st[xf*2+1].F.S}, {(st[xf*2].S.F||(st[xf*2].S.S*st[xf*2+1].F.F*st[xf*2+1].F.S*st[xf*2].F.F)>=1e9), st[xf*2+1].S.S}};
      |                                                                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:41:38: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   41 |         st[i+n]={{a[i], b[i]}, {(a[i]*b[i]>=1e9), 1}};
      |                                  ~~~~^~~~~
horses.cpp:43:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   43 |     for(int i=n-1; i>0; i--){
      |               ~^~
horses.cpp:46:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   46 |  return (st[1].F.F*st[1].F.S)%mod;
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:51:42: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   51 |     st[pos+n]={{a[pos], b[pos]}, {(a[pos]*b[pos]>=1e9), 1}};
      |                                    ~~~~~~^~~~~~~
horses.cpp:53:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   53 |  return (st[1].F.F*st[1].F.S)%mod;
      |         ~~~~~~~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:58:42: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
   58 |     st[pos+n]={{a[pos], b[pos]}, {(a[pos]*b[pos]>=1e9), 1}};
      |                                    ~~~~~~^~~~~~~
horses.cpp:60:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   60 |  return (st[1].F.F*st[1].F.S)%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...