제출 #1218967

#제출 시각아이디문제언어결과실행 시간메모리
1218967LIA말 (IOI15_horses)C++17
34 / 100
1597 ms20008 KiB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple <ll,ll,ll> plll;
typedef vector <plll> vplll;
typedef pair <ll,ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <vector <pll>> vvpll;
typedef vector <vector <ll>> vvll;
typedef vector <bool> vb;
typedef vector <vector <bool>> vvb;
#define loop(i, s, e) for (ll i = (s); i < (e); ++i)
#define loopr(i, e, s) for (ll i = (e)-1; i >= (s); --i)
#define all(a) a.begin(), a.end()
const ll inf = 1e9 + 7;

vector<double> x,y;
vll X,Y;
ll n;

int init(int N, int X1[], int Y1[]) {
    n = N;
    x.resize(n);
    y.resize(n);
    X.resize(n);
    Y.resize(n);
    loop(i,0,n) {
        x[i] = log2((double)X1[i]);
        y[i] = log2((double)Y1[i]);
        X[i] = X1[i];
        Y[i] = Y1[i];
    }
    ll idx = 0;
    double best = -1e300, cur = 0;
    loop(i,0,n) {
        cur += x[i];
        if (cur + y[i] > best) {
            best = cur + y[i];
            idx = i;
        }
    }
    ll ansi = 1;
    loop(i,0, idx+1) ansi = (ansi * X[i]) % inf;
    ansi = (ansi * Y[idx]) % inf;
    return ansi;
}

int updateX(int pos, int val) {
    x[pos] = log2((double)val);
    X[pos] = val;
    ll idx = 0;
    double best = -1e300, cur = 0;
    loop(i,0,n) {
        cur += x[i];
        if (cur + y[i] > best) {
            best = cur + y[i];
            idx = i;
        }
    }
    ll ansi = 1;
    loop(i,0, idx+1) ansi = (ansi * X[i]) % inf;
    ansi = (ansi * Y[idx]) % inf;
    return ansi;
}

int updateY(int pos, int val) {
    y[pos] = log2((double)val);
    Y[pos] = val;
    ll idx = 0;
    double best = -1e300, cur = 0;
    loop(i,0,n) {
        cur += x[i];
        if (cur + y[i] > best) {
            best = cur + y[i];
            idx = i;
        }
    }
    ll ansi = 1;
    loop(i,0, idx+1) ansi = (ansi * X[i]) % inf;
    ansi = (ansi * Y[idx]) % inf;
    return ansi;
}
#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...