# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
541225 | new_acc | 말 (IOI15_horses) | C++14 | 138 ms | 46464 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef unsigned long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=5e5+10;
const ll mod=1e9+7;
const int SS=1<<19;
struct item{
ll ilo,ilp,ilk;
int w;
};
pair<ll,ll>t[N];
item seg[(SS<<1)+10];
item comb(item a,item b){
item res;
res.ilo=(a.ilo*b.ilo)%mod;
if(b.ilp==LLONG_MAX){
res.ilp=LLONG_MAX;
res.ilk=b.ilk;
res.w=b.w;
}else{
if(t[a.w].se<a.ilk*b.ilp or t[a.w].se<a.ilk*b.ilp*t[b.w].se){
res.w=b.w;
res.ilk=b.ilk;
if(a.ilp>(ll)1e9 or b.ilp*a.ilk>(ll)1e9) res.ilp=LLONG_MAX;
else res.ilp=a.ilp*a.ilk*b.ilp;
}else{
res.w=a.w;
res.ilp=a.ilp;
res.ilk=a.ilk*b.ilp*b.ilk;
}
}
if(res.ilp>(ll)1e9) res.ilp=LLONG_MAX;
return res;
}
void upd(int ind){
ind+=SS;
seg[ind].w=ind-SS,seg[ind].ilo=t[ind-SS].fi;
seg[ind].ilp=t[ind-SS].fi,seg[ind].ilk=1;
for(ind>>=1;ind>0;ind>>=1) seg[ind]=comb(seg[ind<<1],seg[(ind<<1)+1]);
}
int Query(int a,int b){
ll res=1;
for(a+=SS-1,b+=SS+1;(a>>1)!=(b>>1);a>>=1,b>>=1){
if(!(a&1)) (res*=seg[a+1].ilo)%=mod;
if(b&1) (res*=seg[b-1].ilo)%=mod;
}
return res;
}
int init(int n,int x[],int y[]){
for(int i=0;i<n;i++) t[i+1]={x[i],y[i]};
for(int ind=1;ind<=(SS<<1);ind++) seg[ind].ilo=1,seg[ind].ilp=1,seg[ind].ilk=1;
for(int i=1;i<=n;i++) upd(i);
return Query(1,seg[1].w)*t[seg[1].w].se;
}
int updateX(int pos,int val){
pos++;
t[pos].fi=val;
upd(pos);
return Query(1,seg[1].w)*t[seg[1].w].se;
}
int updateY(int pos,int val){
pos++;
t[pos].se=val;
upd(pos);
return Query(1,seg[1].w)*t[seg[1].w].se;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |