답안 #819766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
819766 2023-08-10T13:18:44 Z josanneo22 말 (IOI15_horses) C++17
0 / 100
109 ms 62240 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
#define ld long double
const int N = 5e5 + 500, mod = 1e9 + 7;
int chen(int x, int y) {return ((x % mod) * (y % mod)) % mod;}
int jia(int x, int y) { return ((x % mod) + (y % mod)) % mod; }
int a[N], b[N];
struct yl {
    int l, r, pro, ans;
    ld sumlog, mx;
}tr[N << 2];
void pushup(int p) {
    int l = p << 1, r = p << 1 | 1;
    tr[p].sumlog = tr[l].sumlog + tr[r].sumlog;
    tr[p].pro = chen(tr[l].pro, tr[r].pro);
    if (tr[l].mx < tr[l].sumlog + tr[r].mx) {
        tr[p].mx = tr[l].sumlog + tr[r].mx;
        tr[p].ans = chen(tr[l].pro , tr[r].ans);
    }
    else {
        tr[p].mx = tr[l].mx;
        tr[p].ans = tr[l].ans;
    }
    return;
}
void build(int p, int l, int r) {
    tr[p].l = l; tr[p].r = r;
    if (l == r) {
        tr[p].ans = chen(a[l], b[l]); 
        tr[p].pro = a[l] % mod;
        tr[p].sumlog = log(a[l]);
        tr[p].mx = log(a[l] * b[l]);
        return;
    }
    int mid = (l + r) >> 1;
    build(p << 1, l, mid); build(p << 1 | 1, mid + 1, r);
    pushup(p);
    return;
}
void modify(int p, int l) {
    if (tr[p].l == tr[p].r) {
        tr[p].ans = chen(a[l], b[l]);
        tr[p].pro = a[l] % mod;
        tr[p].sumlog = log(a[l]);
        tr[p].mx = log(a[l] * b[l]);
        return;
    }
    int mid = (tr[p].l + tr[p].r) >> 1;
    if (l <= mid) modify(p << 1, l);
    if (l > mid) modify(p << 1 | 1, l);
    pushup(p);
    return;
}
int init(int N, int X[], int Y[]) {
	int n=N;
	for (int i = 1; i <= n; i++) a[i]=X[i-1];
    for (int i = 1; i <= n; i++) b[i]=Y[i-1];
    build(1,1,n);
	return 0;
}

int updateX(int pos, int val) {	
	a[pos+1]=val; modify(1,pos+1);
	return tr[1].ans;
}

int updateY(int pos, int val) {
	b[pos+1]=val; modify(1,pos+1);
	return tr[1].ans;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:55:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   55 | int init(int N, int X[], int Y[]) {
      |          ~~~~^
horses.cpp:5:11: note: shadowed declaration is here
    5 | const int N = 5e5 + 500, mod = 1e9 + 7;
      |           ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 109 ms 62240 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -