Submission #220361

#TimeUsernameProblemLanguageResultExecution timeMemory
220361giorgikobHorses (IOI15_horses)C++14
0 / 100
1593 ms12288 KiB
typedef long long ll; const int mod = 1e9+7; int jump[1000000]; //int beg[1000000]; int X[1000000]; int Y[1000000]; int N; int get_idx(int l,int r){ if(l == r){ return l; } int mid = l+r; mid >>= 1; int x = get_idx(l,mid); int y = get_idx(mid+1,r); ll cnt = 1; for(int i = x+1; i <= y; i++){ if(jump[i] != -1){ i = jump[i]; continue; } cnt *= X[i]; if(cnt > Y[x]){ break; } } return (cnt > Y[x]) ? y : x; } int calc(int pos){ ll cnt = 1; for(int i = 0; i < pos; i++){ cnt *= X[i]; cnt %= mod; } cnt *= Y[pos]; cnt %= mod; return (int)cnt; } void go(){ for(int i = 0; i < N; i++){ if(X[i] == 1){ int l = i; while(i+1 < N && X[i+1] == 0) i++; while(l != i) jump[l] = i, l++; } } } int init(int n, int x[], int y[]) { N = n; for(int i = 0; i < N; i++){ jump[i] = -1; //beg[i] = -1; X[i] = x[i]; Y[i] = y[i]; } go(); int idx = get_idx(0,N); return calc(idx); } int updateX(int pos, int val) { X[pos] = val; go(); int idx = get_idx(0,N); return calc(idx); } int updateY(int pos, int val) { Y[pos] = val; int idx = get_idx(0,N); return calc(idx); }
#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...