Submission #206318

#TimeUsernameProblemLanguageResultExecution timeMemory
206318okoHorses (IOI15_horses)C++14
54 / 100
1592 ms22612 KiB
#include "horses.h" #include <stdio.h> #include <stdlib.h> #include <bits/stdc++.h> using namespace std; long long n,a[500500],b[500500],mod=1e9+7,tree[2005000]; long long qrx(int nod,int l,int r,int x,int y) { if(x<=l&&r<=y)return tree[nod]; else if(r<x||y<l)return 1ll; int mid=(l+r)/2; return (qrx(nod*2,l,mid,x,y)*qrx(nod*2+1,mid+1,r,x,y))%mod; } void upx(int nod,int l,int r,int x,long long val) { if(x<l||r<x)return; if(l==r) { tree[nod]=val; return; } int mid=(l+r)/2; upx(nod*2,l,mid,x,val); upx(nod*2+1,mid+1,r,x,val); tree[nod]=(tree[nod*2]*tree[nod*2+1])%mod; } long long slov() { long long x=1,ans=0,st; int i=n-1; while(1) { x*=a[i]; if(x>(long long)2e9)break; st=i; if(i==0)break; i--; } if(st)ans=b[st-1]; x=1; for(int i=st;i<n;i++) { x*=a[i]; ans=max(ans,x*b[i]); } ans%=mod; ans*=qrx(1,0,n+5,0,st-1); return ans%mod; } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<n;i++) { a[i]=X[i]; upx(1,0,n+5,i,a[i]); b[i]=Y[i]; } return slov(); } int updateX(int pos, int val) { a[pos]=val; upx(1,0,n+5,pos,val); return slov(); } int updateY(int pos, int val) { b[pos]=val; return slov(); }

Compilation message (stderr)

horses.cpp: In function 'long long int slov()':
horses.cpp:30:12: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     int i=n-1;
           ~^~
horses.cpp:41:13: warning: declaration of 'i' shadows a previous local [-Wshadow]
     for(int i=st;i<n;i++)
             ^
horses.cpp:30:9: note: shadowed declaration is here
     int i=n-1;
         ^
horses.cpp:41:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     for(int i=st;i<n;i++)
               ^~
horses.cpp:47:19: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     ans*=qrx(1,0,n+5,0,st-1);
                  ~^~
horses.cpp:47:26: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     ans*=qrx(1,0,n+5,0,st-1);
                        ~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:56:18: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
         upx(1,0,n+5,i,a[i]);
                 ~^~
horses.cpp:59:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return slov();
            ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:64:14: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     upx(1,0,n+5,pos,val);
             ~^~
horses.cpp:65:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return slov();
            ~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:70:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return slov();
            ~~~~^~
horses.cpp: In function 'long long int slov()':
horses.cpp:29:25: warning: 'st' may be used uninitialized in this function [-Wmaybe-uninitialized]
     long long x=1,ans=0,st;
                         ^~
#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...