Submission #1302239

#TimeUsernameProblemLanguageResultExecution timeMemory
1302239nicolo_010Horses (IOI15_horses)C++20
17 / 100
1595 ms17700 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; 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]); } } ll ans=0; ll am=1; for (int i=0; i<(int)xx.size(); i++) { am *= xx[i]; am %= MOD; ans = max(ans, am*yy[i]); ans %= MOD; } return ans; } 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]); } } ll ans=0; ll am=1; for (int i=0; i<(int)xx.size(); i++) { am *= xx[i]; am %= MOD; ans = max(ans, am*yy[i]); ans %= MOD; } return ans; } 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]); } } ll ans=0; ll am=1; for (int i=0; i<(int)xx.size(); i++) { am *= xx[i]; am %= MOD; ans = max(ans, am*yy[i]); ans %= MOD; } return ans; }
#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...