이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "horses.h"
typedef long long int64;
using namespace std;
const int64 mod = 1e9 + 7;
const int maxn = 5e5 + 2;
int n;
struct node {
int64 v;
int64 x;
int64 y;
double dv;
double dx;
double dy;
} sgt [4 * maxn];
node merge (node a, node b) {
node rs;
b.dx+=a.dx, b.dv+=a.dx;
if (a.dv > b.dv) rs.v = a.v, rs.dv = a.dv;
else rs.v = a.x * b.v % mod, rs.dv = b.dv;
rs.x = a.x * b.x % mod;
rs.dx = b.dx;
return rs;
}
node update (int x, int l, int r, int ps, int64 vx, int64 vy) {
if (l > ps || r < ps) return sgt[x];
if (l == r && l == ps) {
node& nd = sgt[x];
if (vx) nd.dx = log(vx), nd.x = vx;
if (vy) nd.dy = log(vy), nd.y = vy;
nd.v = nd.x * nd.y % mod, nd.dv = nd.dx + nd.dy;
return nd;
}
int mid = (l + r) / 2;
return sgt[x] = merge(update(x * 2, l, mid, ps, vx, vy), update(x * 2 + 1, mid + 1, ps, ps, vx, vy));
}
int init(int N, int X[], int Y[]) {
n = N;
for (int i = 0; i < N; i++){
update(1, 0, n - 1, i, X[i], Y[i]);
}
return sgt[1].v;
}
int updateX(int pos, int val) {
cout << "\n\n";
update(1, 0, n - 1, pos, val, 0);
return sgt[1].v;
}
int updateY(int pos, int val) {
cout << "\n\n";
update(1, 0, n - 1, pos, 0, val);
return sgt[1].v;
}
컴파일 시 표준 에러 (stderr) 메시지
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:45:16: warning: conversion from 'int64' {aka 'long long int'} to 'int' may change value [-Wconversion]
45 | return sgt[1].v;
| ~~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:51:16: warning: conversion from 'int64' {aka 'long long int'} to 'int' may change value [-Wconversion]
51 | return sgt[1].v;
| ~~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:57:16: warning: conversion from 'int64' {aka 'long long int'} to 'int' may change value [-Wconversion]
57 | return sgt[1].v;
| ~~~~~~~^
# | 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... |