제출 #69843

#제출 시각아이디문제언어결과실행 시간메모리
69843Vahan말 (IOI15_horses)C++17
54 / 100
561 ms201992 KiB
#include "horses.h" #include<cmath> #include<iostream> using namespace std; pair<double,long long> t[3000000],mec[3000000]; double lp[600000]; long long p[600000],n,x[600000],y[600000]; long long mod=1000000007; void build(int l,int r,int v) { t[v].second=1; if(l==r) { t[v].first=lp[l]; mec[v].first=lp[l]; t[v].second=p[l]; mec[v].second=p[l]; return; } int mid=(l+r)/2; build(l,mid,2*v); build(mid+1,r,2*v+1); mec[v]=max(mec[2*v],mec[2*v+1]); } void update(int L,int R,int l,int r,int v,long long e,double f) { if(l>r) return; if(l==L && r==R) { t[v].first+=f; t[v].second*=e; mec[v].first+=f; mec[v].second*=e; mec[v].second%=mod; t[v].second%=mod; return; } int mid=(L+R)/2; update(L,mid,l,min(mid,r),2*v,e,f); update(mid+1,R,max(l,mid+1),r,2*v+1,e,f); mec[v]=max(mec[2*v],mec[2*v+1]); mec[v].first+=t[v].first; mec[v].second*=t[v].second; mec[v].second%=mod; } 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]; } for(int i=0;i<N;i++) { p[i]=X[i]; lp[i]+=log(X[i]); if(i>0) { p[i]=(p[i]*p[i-1])%mod; lp[i]+=lp[i-1]; } } for(int i=0;i<N;i++) { p[i]=(p[i]*Y[i])%mod; lp[i]+=log(Y[i]); } build(0,n-1,1); return mec[1].second; } long long binpow(long long a,long long b) { if(b==0) return 1; if(b%2==0) { long long arm=binpow(a,b/2); return (arm*arm)%mod; } return (a*binpow(a,b-1))%mod; } int updateX(int pos, int val) { long long e=(binpow(x[pos],mod-2)*val)%mod; double f=log(val)-log(x[pos]); x[pos]=val; update(0,n-1,pos,n-1,1,e,f); return mec[1].second; } int updateY(int pos, int val) { long long e=(binpow(y[pos],mod-2)*val)%mod; double f=log(val)-log(y[pos]); y[pos]=val; update(0,n-1,pos,pos,1,e,f); return mec[1].second; }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:69:14: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     build(0,n-1,1);
             ~^~
horses.cpp:70:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return mec[1].second;
         ~~~~~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:87:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     update(0,n-1,pos,n-1,1,e,f);
              ~^~
horses.cpp:87:23: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     update(0,n-1,pos,n-1,1,e,f);
                      ~^~
horses.cpp:88:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return mec[1].second;
         ~~~~~~~^~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:95:15: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
     update(0,n-1,pos,pos,1,e,f);
              ~^~
horses.cpp:96:16: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return mec[1].second;
         ~~~~~~~^~~~~~
#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...