이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "horses.h"
using namespace std;
using ll = long long;
const ll MAX_N = 4e6 + 2;
const ll mod = 1e9 + 7;
struct node{
ll v, x, y; double dx, dy, dv;
}t[4 * 500005];
int n;
node merge(node a, node b) {
node res;
b.dx += a.dx;
b.dv += a.dx;
if ( a.dv > b.dv) res.v = a.v, res.dv = a.dv;
else res.v = (a.x * b.v)% mod, res.dv = b.dv;
res.x = a.x * b.x % mod;
res.dx = b.dx;
return res;
}
node upd(ll p, ll lo, ll hi, ll ind, ll x, ll y) {
if (lo > ind || ind > hi) return t[p];
if (lo == hi) {
node& nd = t[p];
if ( x != -1) nd.dx = log(x), nd.x =x;
if ( y != -1) nd.dy = log(y), nd.y =y;
nd.v = (nd.x * nd.y) % mod;
nd.dv = nd.dx + nd.dy;
return nd;
}
int mid = (lo +hi)/2;
return t[p] = merge(upd(2 * p, lo, mid, ind, x, y), upd(2 * p + 1, mid + 1, hi, ind, x, y));
}
int init(int N, int X[], int Y[]) {
n = N;
for (int i = 0; i < N; i++) upd(1, 0, n - 1, i, X[i], Y[i]);
return t[1].v;
}
int updateX(int pos, int val) {
upd(1, 0, n - 1, pos, val, -1);
return t[1].v;
}
int updateY(int pos, int val) {
upd(1, 0, n - 1, pos, -1, val);
return t[1].x;
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'node upd(ll, ll, ll, ll, ll, ll)':
horses.cpp:34:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
34 | int mid = (lo +hi)/2;
| ~~~~~~~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:41:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
41 | return t[1].v;
| ~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:46:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
46 | return t[1].v;
| ~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:51:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
51 | return t[1].x;
| ~~~~~^
# | 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... |