Submission #982201

# Submission time Handle Problem Language Result Execution time Memory
982201 2024-05-14T02:44:44 Z Amaarsaa Horses (IOI15_horses) C++14
17 / 100
354 ms 54512 KB
#include<bits/stdc++.h>
#include "horses.h"

using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
struct node{
	ll v, x, y; double dx, dy, dv;
}t[4 * 500005];

ll 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 ) nd.dx = log(x), nd.x =x;
		if ( y ) 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, 0);
	return t[1].v;
}

int updateY(int pos, int val) {
	upd(1, 0, n - 1, pos, 0, val);
	return t[1].x;
}

Compilation message

horses.cpp: In function 'node upd(ll, ll, ll, ll, ll, ll)':
horses.cpp:33:20: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   33 |  int mid = (lo +hi)/2;
      |            ~~~~~~~~^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:40:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   40 |  return t[1].v;
      |         ~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:45:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   45 |  return t[1].v;
      |         ~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:50:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   50 |  return t[1].x;
      |         ~~~~~^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 354 ms 54512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 396 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Incorrect 0 ms 348 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Incorrect 0 ms 344 KB Output isn't correct
22 Halted 0 ms 0 KB -