제출 #119719

#제출 시각아이디문제언어결과실행 시간메모리
119719CaroLinda말 (IOI15_horses)C++14
17 / 100
875 ms88908 KiB
#include <bits/stdc++.h> #define lp(i,a,b) for(int i=a;i<b;i++) #define ll long long #define pii pair<int,int> #define ff first #define ss second const int maxn=5e5+10 ; const int MOD=1e9+7 ; using namespace std ; struct node { double a , la ; ll b , lb1 , lb2 ; node() { a = la = 0 ; b = lb1 = lb2 = 1 ; } } ; node tree[4*maxn] ; int m(int l, int r){ return (l+r)/2 ; } void refresh(int pos, int l, int r) { double k1 = tree[pos].la ; ll k2 = tree[pos].lb1 ; ll k3 = tree[pos].lb2 ; tree[pos].la = 0 ; tree[pos].lb1 = 1 ; tree[pos].lb2 = 1 ; tree[pos].b = (tree[pos].b/k3) ; tree[pos].b = (tree[pos].b*k2) % MOD ; tree[pos].a += k1 ; if(l==r) return ; lp(i,0,2) { tree[pos*2+i].la += k1 ; tree[pos*2+i].lb1 = (tree[pos*2+i].lb1*k2) % MOD ; tree[pos*2+i].lb2 = (tree[pos*2+i].lb2*k3) % MOD ; } } void merge(int pos) { tree[pos].a = max(tree[pos*2].a, tree[pos*2+1].a) ; tree[pos].b = (tree[pos*2].a > tree[pos*2+1].a) ? tree[pos*2].b : tree[pos*2+1].b ; } void pointUpd(int pos, int l, int r ,int x, double v, ll b1 , ll b2) { refresh(pos,l,r) ; if(l>x or r < x) return ; if(l==r) { tree[pos].a += v ; tree[pos].b = (tree[pos].b*b1)%MOD ; tree[pos].b = (tree[pos].b/b2) % MOD ; return ; } pointUpd(pos*2,l,m(l,r),x,v,b1,b2) ; pointUpd(pos*2+1,m(l,r)+1,r,x,v,b1,b2) ; merge(pos) ; } void intervalUpd(int pos, int l, int r , int beg, int en, double v, ll b1 ,ll b2) { refresh(pos, l, r) ; if(l>en or r < beg) return ; if(l>=beg && r<=en) { tree[pos].la += v ; tree[pos].lb1 = (tree[pos].lb1*b1) % MOD ; tree[pos].lb2 = (tree[pos].lb2*b2) % MOD ; refresh(pos, l, r) ; return ; } intervalUpd(pos*2, l,m(l,r),beg,en,v,b1,b2) ; intervalUpd(pos*2+1,m(l,r)+1,r,beg,en,v,b1,b2) ; merge(pos) ; } void print(int pos, int l, int r) { refresh(pos,l,r) ; printf("%d e %d: %lld\n", l,r,tree[pos].b) ; if(l==r) return ; print(pos*2,l,m(l,r)) ; print(pos*2+1,m(l,r)+1,r) ; } // -------- x -------- int n , x[maxn] , y[maxn] ; ll ans() { refresh(1,0,n-1) ; return tree[1].b ; } int updateY(int pos, int val) { pointUpd(1,0,n-1,pos,-log2(y[pos]),1,y[pos]) ; pointUpd(1,0,n-1,pos,log2(val),val,1) ; y[pos] = val ; return ans() ; } int updateX(int pos, int val) { intervalUpd(1,0,n-1,pos,n-1,-log2(x[pos]), 1, x[pos]) ; intervalUpd(1,0,n-1,pos,n-1,log2(val),val,1) ; x[pos] = val ; return ans() ; } int init(int N, int X[], int Y[]) { n = N ; lp(i,0,n) x[i] = X[i] ; lp(i,0,n) y[i]=Y[i] ; ll acProduct=1 ; double logProduct = log2(1) ; lp(i,0,n) { acProduct = (acProduct*x[i]) % MOD ; logProduct += log2(x[i]) ; pointUpd(1,0,n-1,i,log2(y[i]) + logProduct , (acProduct*y[i])%MOD,1 ) ; } return ans(); }

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

horses.cpp: In function 'int updateY(int, int)':
horses.cpp:121:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   return ans() ;
          ~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:129:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   return ans() ;
          ~~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:150:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
   return ans();
          ~~~^~
#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...