Submission #846804

# Submission time Handle Problem Language Result Execution time Memory
846804 2023-09-08T13:18:49 Z 12345678 Horses (IOI15_horses) C++17
17 / 100
175 ms 54356 KB
#include "horses.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll nx=5e5+5, mod=1e9+7, mx=(ll)INT_MAX+1;
int n;
vector<ll> x, y;

struct segtree
{
	struct node
	{
		ll pre, suf, sm, ans, p; 
	} d[4*nx];
	ll a[nx], b[nx];
	void update(int l, int r, int i, int idx, ll vx, ll vy)
	{
		if (r<idx||idx<l) return;
		if (l==r)
		{
			d[i].ans=(vx*vy)%mod;
			d[i].pre=d[i].sm=vx;
			d[i].suf=1; d[i].p=vy;
			return;
		}
		int md=(l+r)/2;
		update(l, md, 2*i, idx, vx, vy);
		update(md+1, r, 2*i+1, idx, vx, vy);
		if (d[2*i].p<min(d[2*i].suf*d[2*i+1].pre, mx)*d[2*i+1].p)
		{
			d[i].ans=(d[2*i].sm*d[2*i+1].ans)%mod;
			d[i].pre=min(d[2*i].sm*d[2*i+1].pre, mx);
			d[i].sm=min(d[2*i].sm*d[2*i+1].sm, mx);
			d[i].suf=d[2*i+1].suf;
			d[i].p=d[2*i+1].p;
		}
		else
		{
			d[i].ans=d[2*i].ans;
			d[i].pre=d[2*i].pre;
			d[i].sm=min(d[2*i].sm*d[2*i+1].sm, mx);
			d[i].suf=min(d[2*i].suf*d[2*i+1].sm, mx);
			d[i].p=d[2*i].p;
		}
	}
} s;

int init(int N, int X[], int Y[]) {
	n=N;
	x.resize(N+1); y.resize(N+1);
	for (int i=1; i<=N; i++) s.update(1, n, 1, i, X[i-1], Y[i-1]), x[i]=X[i-1], y[i]=Y[i-1];
	return s.d[1].ans;
}

int updateX(int pos, int val) {	
	x[pos+1]=val;
	s.update(1, n, 1, pos+1, x[pos+1], y[pos+1]);
	return s.d[1].ans;
}

int updateY(int pos, int val) {
	y[pos+1]=val;
	s.update(1, n, 1, pos+1, x[pos+1], y[pos+1]);
	return s.d[1].ans;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:55:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   55 |  return s.d[1].ans;
      |         ~~~~~~~^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:61:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   61 |  return s.d[1].ans;
      |         ~~~~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:67:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   67 |  return s.d[1].ans;
      |         ~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 1 ms 348 KB Output is correct
6 Correct 1 ms 432 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 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 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 0 ms 348 KB Output is correct
20 Correct 1 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 344 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 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 500 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 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Incorrect 0 ms 348 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 175 ms 54356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 356 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 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 0 ms 348 KB Output is correct
17 Correct 1 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 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Incorrect 0 ms 348 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 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 344 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 1 ms 348 KB Output is correct
8 Correct 1 ms 344 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 1 ms 344 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 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Incorrect 1 ms 344 KB Output isn't correct
23 Halted 0 ms 0 KB -