Submission #1302246

#TimeUsernameProblemLanguageResultExecution timeMemory
1302246nicolo_010Horses (IOI15_horses)C++20
17 / 100
1596 ms21604 KiB
#include <bits/stdc++.h> #include "horses.h" using namespace std; using ll = long long; using pii = pair<int, int>; const int MOD = 1e9+7; const ll INF = 1e18; int* x; int* y; int n; ll compute(vector<ll> a, vector<ll> b) { int idx=0; ll prod=1; bool moduled = false; for (int i=1; i<(int)a.size(); i++) { ll y0 = b[idx]; ll y1 = b[i]; prod *= x[i]; if (prod >= MOD) { moduled = true; prod %= MOD; } if (moduled) { //Se que y[i] <= y[j]*prod //Conviene j idx = i; moduled = 0; prod = 1; } else { if (prod*y1 >= y0) { idx = i; prod = 1; moduled = false; } } } prod=a[0]; for (int i=1; i<n; i++) { if (i > idx) break; prod *= a[i]; prod %= MOD; } return (prod*b[idx]) % MOD; } int init(int N, int* a, int* b) { x = a; y = b; n = N; vector<ll> xx, yy; xx.push_back(x[0]); yy.push_back(y[0]); for (int i=1; i<n; i++) { if (x[i] == 1) { yy.back() = max(yy.back(), (ll)y[i]); } else { xx.push_back(x[i]); yy.push_back(y[i]); } } return compute(xx, yy); } int updateX(int pos, int val) { x[pos] = val; vector<ll> xx, yy; xx.push_back(x[0]); yy.push_back(y[0]); for (int i=1; i<n; i++) { if (x[i] == 1) { yy.back() = max(yy.back(), (ll)y[i]); } else { xx.push_back(x[i]); yy.push_back(y[i]); } } return compute(xx, yy); } int updateY(int pos, int val) { y[pos] = val; vector<ll> xx, yy; xx.push_back(x[0]); yy.push_back(y[0]); for (int i=1; i<n; i++) { if (x[i] == 1) { yy.back() = max(yy.back(), (ll)y[i]); } else { xx.push_back(x[i]); yy.push_back(y[i]); } } return compute(xx, yy); }
#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...