Submission #640018

#TimeUsernameProblemLanguageResultExecution timeMemory
640018ggohHorses (IOI15_horses)C++14
100 / 100
1294 ms79496 KiB
#include "horses.h" #include<bits/stdc++.h> using namespace std; #define sz(v) ((int)(v).size()) typedef long long lint; typedef pair<int,int> pii; lint Z=1e9+7; int n; lint po(lint p,int q) { if(q==0)return 1; if(q==1)return p; lint o=po(p,q/2); o=o*o%Z; if(q%2)o=o*p%Z; return o; } struct Tree{ long double l; lint v; }seg[1<<20]; long double lazyL[1<<20]; lint lazyV[1<<20]; vector<int>XX,YY; void push(int num,int s,int e) { seg[num].l+=lazyL[num]; if(s!=e) { lazyL[2*num]+=lazyL[num]; lazyL[2*num+1]+=lazyL[num]; } lazyL[num]=0; seg[num].v=seg[num].v*lazyV[num]%Z; if(s!=e) { lazyV[2*num]=lazyV[2*num]*lazyV[num]%Z; lazyV[2*num+1]=lazyV[2*num+1]*lazyV[num]%Z; } lazyV[num]=1; } void update(int num,int s,int e,int l,int r,long double x,lint z) { push(num,s,e); if(s>r||l>e)return ; if(l<=s&&e<=r) { seg[num].l+=x; seg[num].v=seg[num].v*z%Z; if(s!=e) { lazyL[num*2]+=x; lazyL[num*2+1]+=x; lazyV[num*2]=lazyV[num*2]*z%Z; lazyV[num*2+1]=lazyV[num*2+1]*z%Z; } return ; } update(num*2,s,(s+e)/2,l,r,x,z); update(num*2+1,(s+e)/2+1,e,l,r,x,z); if(seg[num*2].l>seg[num*2+1].l) { seg[num].l=seg[num*2].l; seg[num].v=seg[num*2].v; } else { seg[num].l=seg[num*2+1].l; seg[num].v=seg[num*2+1].v; } } int init(int N, int X[], int Y[]) { n=N; for(int i=1;i<(1<<20);i++)lazyV[i]=seg[i].v=1; for(int i=0;i<n;i++) { long double x=log(X[i]); long double y=log(Y[i]); XX.push_back(X[i]); YY.push_back(Y[i]); update(1,0,n-1,i,n-1,x,X[i]); update(1,0,n-1,i,i,y,Y[i]); } return (int)seg[1].v; } int updateX(int pos, int val) { long double x0=log(XX[pos]); long double x1=log(val); lint mul=po(XX[pos],Z-2)*val%Z; XX[pos]=val; update(1,0,n-1,pos,n-1,x1-x0,mul); return (int)seg[1].v; } int updateY(int pos, int val) { long double y0=log(YY[pos]); long double y1=log(val); lint mul=po(YY[pos],Z-2)*val%Z; YY[pos]=val; update(1,0,n-1,pos,pos,y1-y0,mul); return (int)seg[1].v; }

Compilation message (stderr)

horses.cpp: In function 'int updateX(int, int)':
horses.cpp:93:23: warning: conversion from 'lint' {aka 'long long int'} to 'int' may change value [-Wconversion]
   93 |  lint mul=po(XX[pos],Z-2)*val%Z;
      |                      ~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:102:23: warning: conversion from 'lint' {aka 'long long int'} to 'int' may change value [-Wconversion]
  102 |  lint mul=po(YY[pos],Z-2)*val%Z;
      |                      ~^~
#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...