답안 #601577

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
601577 2022-07-22T08:15:01 Z Vanilla 말 (IOI15_horses) C++17
0 / 100
426 ms 4892 KB
#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) {	
	update(1, 0, n - 1, pos, val, 0);
	return sgt[1].v;
}

int updateY(int pos, int val) {
	update(1, 0, n - 1, pos, 0, val);
	return sgt[1].v;
}

Compilation message

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:50:16: warning: conversion from 'int64' {aka 'long long int'} to 'int' may change value [-Wconversion]
   50 |  return sgt[1].v;
      |         ~~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:55:16: warning: conversion from 'int64' {aka 'long long int'} to 'int' may change value [-Wconversion]
   55 |  return sgt[1].v;
      |         ~~~~~~~^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 426 ms 4892 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -