이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define ll long long
const int NMAX = (int)1e5 * 6;
const ll MOD = (int)1e9 + 7;
int A[NMAX],B[NMAX],n;
ll over_two[NMAX],prod[NMAX];
ll POW(ll x,int p) {
ll res = 1;
while (p) {
if (p % 2)
res = res * x % MOD;
p /= 2;
x = x * x % MOD;
}
return res;
}
int init(int N, int X[], int Y[]) {
prod[0] = 1;
for (int i = 0; i < N;++i) {
A[i] = X[i];
B[i] = Y[i];
over_two[i] = (X[i] >= 2);
prod[i] = X[i];
if (i) {
over_two[i] += over_two[i - 1];
prod[i] = prod[i] * prod[i - 1] % MOD;
}
}
n = N;
ll ans = (ll)X[0] * (ll)Y[0] % MOD;
ll y_ans = Y[0];
int i_ans = 0;
ll x = X[0];
for (int i = 1; i < N;++i) {
x = x * (ll)X[i] % MOD;
bool ok = false;
if (over_two[i] - over_two[i_ans] > 30)
ok = true;
if (Y[i] * (prod[i] * POW(prod[i_ans],MOD - 2) % MOD) > y_ans)
ok = true;
if (ok) {
y_ans = Y[i];
i_ans = i;
ans = x * Y[i] % MOD;
}
}
return ans;
}
int updateX(int pos, int val) {
A[pos] = val;
return init(n,A,B);
}
int updateY(int pos, int val) {
B[pos] = val;
return init(n,A,B);
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:52:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
52 | return ans;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |