Submission #259308

#TimeUsernameProblemLanguageResultExecution timeMemory
259308IOrtroiiiHorses (IOI15_horses)C++14
0 / 100
423 ms63108 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int MX = 500500; int N; int X[MX], Y[MX]; namespace searcher { pair<ld, int> best[MX << 1]; ld sum[MX << 1]; void pop(int v) { best[v] = max(best[v << 1], make_pair(best[v << 1 | 1].first + sum[v << 1], best[v].second)); sum[v] = sum[v << 1] + sum[v << 1 | 1]; } void modify(int p) { p += N; best[p] = make_pair(log(X[p - N]) + log(Y[p - N]), p - N); sum[p] = log(X[p - N]); for (p >>= 1; p > 0; p >>= 1) { pop(p); } } }; namespace calculator { static const int MOD = 1000000007; int mult(int x, int y) { return ll(x) * y % MOD; } int st[MX << 1]; void modify(int p) { p += N; st[p] = X[p - N]; for (p >>= 1; p > 0; p >>= 1) { st[p] = mult(st[p << 1], st[p << 1 | 1]); } } int query(int p) { int ans = Y[p]; for (int l = N, r = p + N; l <= r; l >>= 1, r >>= 1) { if (l & 1) ans = mult(ans, st[l++]); if (!(r & 1)) ans = mult(ans, st[r--]); } return ans; } }; void 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) { searcher::modify(i); calculator::modify(i); } } int updateX(int pos, int val) { X[pos] = val; searcher::modify(pos); calculator::modify(pos); return calculator::query(searcher::best[1].second); } int updateY(int pos, int val) { Y[pos] = val; searcher::modify(pos); calculator::modify(pos); return calculator::query(searcher::best[1].second); }

Compilation message (stderr)

horses.cpp: In function 'int calculator::mult(int, int)':
horses.cpp:37:43: warning: conversion to 'int' from 'll {aka long long int}' may alter its value [-Wconversion]
 int mult(int x, int y) { return ll(x) * y % MOD; }
                                 ~~~~~~~~~~^~~~~
#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...