Submission #68989

#TimeUsernameProblemLanguageResultExecution timeMemory
68989theknife2001Horses (IOI15_horses)C++17
17 / 100
229 ms21644 KiB
#include "horses.h" //#include "grader.cpp" #include <bits/stdc++.h> #define mid (l+r)/2 using namespace std; const int N=5e5+55; long long tree[N*4]; long long x[N]; long long y[N]; int n; int m=1e9+7; void build(int l , int r , int node) { if(l==r) { tree[node]=x[l]; return ; } build(l,mid,node*2); build(mid+1,r,node*2+1); tree[node]=tree[node*2]*tree[node*2+1]; tree[node]%=m; } void update(int l , int r , int node , int ind , int val) { if(l==r&&l==ind) { tree[node]=val; return ; } if(ind<=mid) update(l,mid,node*2,ind,val); else update(mid+1,r,node*2+1,ind,val); tree[node]=tree[node*2]*tree[node*2+1]; tree[node]%=m; } long long query(int l , int r , int node , int x , int y) { if(x<=l&&r<=y) return tree[node]; if(l>y||r<x) return 1; return (query(l,mid,node*2,x,y)*query(mid+1,r,node*2+1,x,y))%m; } int solve() { int i=n-1; long long ret=0; long long temp=1; long long s=1; while(i--) { s*=x[i]; if(s>10000000000) break; } i++; int bestpos=n-1; for(;i<n;i++) { temp*=x[i]; if(y[i]*temp>ret) { ret=y[i]*temp; bestpos=i; } } return (y[bestpos]*query(0,n-1,1,0,bestpos))%m; } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<N;i++) { x[i]=X[i]; y[i]=Y[i]; } build(0,n-1,1); return solve(); } int updateX(int pos, int val) { x[pos]=val; update(0,n-1,1,pos,val); return solve(); } int updateY(int pos, int val) { y[pos]=val; return solve(); }

Compilation message (stderr)

horses.cpp: In function 'long long int query(int, int, int, int, int)':
horses.cpp:42:57: warning: declaration of 'y' shadows a global declaration [-Wshadow]
 long long query(int l , int r , int node , int x , int y)
                                                         ^
horses.cpp:10:11: note: shadowed declaration is here
 long long y[N];
           ^
horses.cpp:42:57: warning: declaration of 'x' shadows a global declaration [-Wshadow]
 long long query(int l , int r , int node , int x , int y)
                                                         ^
horses.cpp:9:11: note: shadowed declaration is here
 long long x[N];
           ^
horses.cpp: In function 'int solve()':
horses.cpp:74:49: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     return (y[bestpos]*query(0,n-1,1,0,bestpos))%m;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:77:33: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 int init(int N, int X[], int Y[])
                                 ^
horses.cpp:7:11: note: shadowed declaration is here
 const int N=5e5+55;
           ^
#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...