Submission #1359138

#TimeUsernameProblemLanguageResultExecution timeMemory
1359138haithamcoderHorses (IOI15_horses)C++20
17 / 100
1588 ms12180 KiB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

const ll LOG = 31;
const ll MOD = 1000000007;
const ll inf = 1e17;

#define db(x) cerr << #x << " = " << x << " | "
#define dbg(x) cerr << #x << " = " << x << "\n"

ll n;
vector<ll> x, y;

int init(int N, int X[], int Y[]) {
    n = N;
    x.resize(n);
    y.resize(n);
    for (ll i = 0; i < n; i++) x[i] = X[i], y[i] = Y[i];

    return updateX(0, x[0]);
}

int updateX(int pos, int val) {
    ll res = y[n - 1] * x[n - 1];

    x[pos] = val;
    for (ll i = n - 2; i >= 0; i--) {
        res = max(res * x[i], x[i] * y[i]);
    }

	return res % MOD;
}

int updateY(int pos, int val) {
    ll res = y[n - 1] * x[n - 1];

    y[pos] = val;
    for (ll i = n - 2; i >= 0; i--) {
        res = max(res * x[i], x[i] * y[i]);
    }

	return res % MOD;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...