Submission #1080143

#TimeUsernameProblemLanguageResultExecution timeMemory
1080143TrumlingHorses (IOI15_horses)C++14
34 / 100
1562 ms27892 KiB
#include "horses.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define all(x) x.begin(),x.end() #define INF 9999999999999999 #define MOD 1000000007 typedef long long ll; ll n; ll sell; vector<int>x,y; ll seg[2000001]; void build(int idx,int l,int r) { if(l==r) { seg[idx]=x[l]; return ; } build(idx*2,l,(l+r)/2); build(idx*2+1,(l+r)/2+1,r); seg[idx]=(seg[idx*2]*seg[idx*2+1])%MOD; } void update(int idx,int l,int r,int p) { if(r<p || l>p) return ; if(l==r) { seg[idx]=x[p]; return ; } build(idx*2,l,(l+r)/2); build(idx*2+1,(l+r)/2+1,r); seg[idx]=(seg[idx*2]*seg[idx*2+1])%MOD; } ll query(int idx,int L,int R,int l,int r) { if(r<L || l>R) return 1; if(L<=l && r<=R) return seg[idx]; return (query(idx*2,L,R,l,(l+r)/2)*query(idx*2+1,L,R,(l+r)/2+1,r))%MOD; } int init(int N, int X[], int Y[]) { n=N; for(int i=0;i<n;i++) { x.pb(X[i]); y.pb(Y[i]); } build(1,0,n-1); sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; } int updateX(int pos, int val) { x[pos]=val; update(1,0,n-1,pos); sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; } int updateY(int pos, int val) { y[pos]=val; sell=n-1; ll curr=1; for(int i=n-1;i>=0;i--) { if(y[sell]*curr < y[i]) { sell=i; curr=1; } curr*=x[i]; if(curr>=MOD) break; } return (query(1,0,sell,0,n-1)*y[sell])%MOD; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:66:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   66 |  build(1,0,n-1);
      |            ~^~
horses.cpp:70:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   70 |  for(int i=n-1;i>=0;i--)
      |            ~^~
horses.cpp:86:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                    ^~~~
horses.cpp:86:28: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                           ~^~
horses.cpp:86:40: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                                        ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:92:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   92 |  update(1,0,n-1,pos);
      |             ~^~
horses.cpp:95:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   95 |  for(int i=n-1;i>=0;i--)
      |            ~^~
horses.cpp:109:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  109 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                    ^~~~
horses.cpp:109:28: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  109 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                           ~^~
horses.cpp:109:40: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  109 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                                        ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:118:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  118 |  for(int i=n-1;i>=0;i--)
      |            ~^~
horses.cpp:132:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  132 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                    ^~~~
horses.cpp:132:28: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  132 |  return (query(1,0,sell,0,n-1)*y[sell])%MOD;
      |                           ~^~
horses.cpp:132:40: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  132 |  return (query(1,0,sell,0,n-1)*y[sell])%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...