# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
81921 | 2018-10-27T19:23:39 Z | GioChkhaidze | 말 (IOI15_horses) | C++14 | 1259 ms | 61600 KB |
#include "horses.h" #include <bits/stdc++.h> using namespace std; #define Tree int h,int l,int r #define left 2*h,l,(l+r)/2 #define right 2*h+1,(l+r)/2+1,r #define Pb push_back #define F first #define S second long long Inf=1000000008,Mod=1000000007; long long P,n,x[500002],y[500002],ANS; long long Ind,Z; long long v[3000002]; pair < long long , long long > vy[3000002]; set < long long > st; set <long long > :: iterator it; vector < long long > V; pair < long long , long long > X; long long L,R; void Update(Tree) { if (l>L || r<L) return ; if (L==l && r==L) { v[h]=R%Mod; return ; } Update(left); Update(right); v[h]=(1LL*v[2*h]*v[2*h+1])%Mod; } long long Get(Tree) { if (L>r || l>R) return 1; if (L<=l && r<=R) return v[h]; return (1LL*Get(left)*Get(right))%Mod; } void Upy(Tree) { if (l>L || r<L) return ; if (L==l && r==L) { vy[h].F=R; vy[h].S=L; return ; } Upy(left); Upy(right); if (vy[2*h].F>vy[2*h+1].F) vy[h]=vy[2*h]; else vy[h]=vy[2*h+1]; } pair < long long , long long > Gety(Tree) { if (L>r || l>R) return make_pair(0,0); if (L<=l && r<=R) return make_pair(vy[h].F,vy[h].S); pair < long long , long long > X1=Gety(left); pair < long long , long long > X2=Gety(right); if (X1.F>X2.F) return X1; return X2; } 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++) { L=i; R=x[i]; Update(1,0,n-1); if (x[i]>1) st.insert(i); } for (int i=0; i<n; i++) { L=i; R=y[i]; Upy(1,0,n-1); } Ind=0; P=1; for (int j=1; j<n; j++) { if (1LL*P*x[j]<Inf) P*=x[j]; else P=Inf; if (y[Ind]<1LL*P*y[j]) P=1,Ind=j; } L=0; R=Ind; ANS=(1LL*Get(1,0,n-1)*y[Ind])%Mod; return ANS; } long long Ann() { it=st.end(); V.clear(); Z=0; while (it!=st.begin()) { Z++; it--; V.Pb((*it)); if (Z>35) break; } if (!V.size() || V[V.size()-1]!=0) V.Pb(0); reverse(V.begin(),V.end()); if (!V.size() || V[V.size()-1]!=n-1) V.Pb(n-1); Ind=0; P=1; for (int i=0; i<V.size(); i++) { if (1LL*P*x[V[i]]<Inf) P*=x[V[i]]; else P=Inf; if (y[Ind]<1LL*P*y[V[i]]) P=1,Ind=V[i]; if (i==V.size()-1) continue; L=V[i]+1; R=V[i+1]-1; X=Gety(1,0,n-1); if (y[Ind]<1LL*P*X.F) P=1,Ind=X.S; } L=0; R=Ind; ANS=(1LL*Get(1,0,n-1)*y[Ind])%Mod; return ANS; } int updateX(int pos, int val) { if (x[pos]==1 && val>1) st.insert(pos); else if (x[pos]>1 && val==1) st.erase(st.find(pos)); x[pos]=val; Update(1,0,n-1); return Ann(); } int updateY(int pos, int val) { y[pos]=val; Upy(1,0,n-1); return Ann(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 512 KB | Output is correct |
5 | Correct | 2 ms | 512 KB | Output is correct |
6 | Correct | 2 ms | 512 KB | Output is correct |
7 | Correct | 2 ms | 548 KB | Output is correct |
8 | Correct | 2 ms | 676 KB | Output is correct |
9 | Correct | 2 ms | 676 KB | Output is correct |
10 | Correct | 2 ms | 676 KB | Output is correct |
11 | Correct | 2 ms | 676 KB | Output is correct |
12 | Correct | 2 ms | 676 KB | Output is correct |
13 | Correct | 2 ms | 704 KB | Output is correct |
14 | Correct | 2 ms | 704 KB | Output is correct |
15 | Correct | 2 ms | 704 KB | Output is correct |
16 | Correct | 2 ms | 704 KB | Output is correct |
17 | Correct | 2 ms | 704 KB | Output is correct |
18 | Correct | 2 ms | 704 KB | Output is correct |
19 | Correct | 2 ms | 704 KB | Output is correct |
20 | Correct | 2 ms | 704 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 704 KB | Output is correct |
2 | Correct | 2 ms | 704 KB | Output is correct |
3 | Correct | 2 ms | 704 KB | Output is correct |
4 | Correct | 2 ms | 704 KB | Output is correct |
5 | Correct | 2 ms | 704 KB | Output is correct |
6 | Correct | 2 ms | 704 KB | Output is correct |
7 | Correct | 2 ms | 704 KB | Output is correct |
8 | Correct | 2 ms | 704 KB | Output is correct |
9 | Correct | 2 ms | 704 KB | Output is correct |
10 | Correct | 2 ms | 704 KB | Output is correct |
11 | Correct | 2 ms | 704 KB | Output is correct |
12 | Correct | 2 ms | 704 KB | Output is correct |
13 | Correct | 2 ms | 704 KB | Output is correct |
14 | Correct | 2 ms | 704 KB | Output is correct |
15 | Correct | 2 ms | 704 KB | Output is correct |
16 | Correct | 2 ms | 744 KB | Output is correct |
17 | Correct | 2 ms | 744 KB | Output is correct |
18 | Correct | 2 ms | 744 KB | Output is correct |
19 | Correct | 2 ms | 744 KB | Output is correct |
20 | Correct | 2 ms | 744 KB | Output is correct |
21 | Incorrect | 2 ms | 744 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1214 ms | 61416 KB | Output is correct |
2 | Incorrect | 1259 ms | 61600 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 61600 KB | Output is correct |
2 | Correct | 2 ms | 61600 KB | Output is correct |
3 | Correct | 2 ms | 61600 KB | Output is correct |
4 | Correct | 2 ms | 61600 KB | Output is correct |
5 | Correct | 2 ms | 61600 KB | Output is correct |
6 | Correct | 2 ms | 61600 KB | Output is correct |
7 | Correct | 2 ms | 61600 KB | Output is correct |
8 | Correct | 2 ms | 61600 KB | Output is correct |
9 | Correct | 2 ms | 61600 KB | Output is correct |
10 | Correct | 2 ms | 61600 KB | Output is correct |
11 | Correct | 2 ms | 61600 KB | Output is correct |
12 | Correct | 2 ms | 61600 KB | Output is correct |
13 | Correct | 2 ms | 61600 KB | Output is correct |
14 | Correct | 2 ms | 61600 KB | Output is correct |
15 | Correct | 2 ms | 61600 KB | Output is correct |
16 | Correct | 2 ms | 61600 KB | Output is correct |
17 | Correct | 2 ms | 61600 KB | Output is correct |
18 | Correct | 2 ms | 61600 KB | Output is correct |
19 | Correct | 2 ms | 61600 KB | Output is correct |
20 | Correct | 2 ms | 61600 KB | Output is correct |
21 | Incorrect | 2 ms | 61600 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 61600 KB | Output is correct |
2 | Correct | 2 ms | 61600 KB | Output is correct |
3 | Correct | 3 ms | 61600 KB | Output is correct |
4 | Correct | 2 ms | 61600 KB | Output is correct |
5 | Correct | 2 ms | 61600 KB | Output is correct |
6 | Correct | 2 ms | 61600 KB | Output is correct |
7 | Correct | 2 ms | 61600 KB | Output is correct |
8 | Correct | 2 ms | 61600 KB | Output is correct |
9 | Correct | 2 ms | 61600 KB | Output is correct |
10 | Correct | 2 ms | 61600 KB | Output is correct |
11 | Correct | 4 ms | 61600 KB | Output is correct |
12 | Correct | 2 ms | 61600 KB | Output is correct |
13 | Correct | 2 ms | 61600 KB | Output is correct |
14 | Correct | 2 ms | 61600 KB | Output is correct |
15 | Correct | 2 ms | 61600 KB | Output is correct |
16 | Correct | 2 ms | 61600 KB | Output is correct |
17 | Correct | 2 ms | 61600 KB | Output is correct |
18 | Correct | 2 ms | 61600 KB | Output is correct |
19 | Correct | 2 ms | 61600 KB | Output is correct |
20 | Correct | 2 ms | 61600 KB | Output is correct |
21 | Incorrect | 3 ms | 61600 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |