Submission #1056208

# Submission time Handle Problem Language Result Execution time Memory
1056208 2024-08-13T08:15:25 Z Muhammad_Aneeq Horses (IOI15_horses) C++17
100 / 100
238 ms 72376 KB
#include "horses.h"
#include <cmath>
#include <vector>
using namespace std;
int const MAXN=5e5+10,mod=1e9+7;
vector<int>x,y;
struct node
{
	long long val,maxval;
	long double cnt,maxcnt;
};
node seg[4*MAXN]={};
void update(int i,int r,int st,int en)
{
	if (st==en)
	{
		seg[i].val=seg[i].maxval=x[r];
		seg[i].maxval*=y[r];
		seg[i].maxval%=mod;
		seg[i].cnt=log2(x[r]);
		seg[i].maxcnt=seg[i].cnt+log2(y[r]);
		return ;
	}
	int mid=(st+en)/2;
	if (r<=mid)
		update(i*2,r,st,mid);
	else
		update(i*2+1,r,mid+1,en);
	int lc=i*2,rc=i*2+1;
	seg[i].val=(seg[lc].val*seg[rc].val)%mod;
	seg[i].cnt=seg[lc].cnt+seg[rc].cnt;
	if (seg[lc].maxcnt<seg[lc].cnt+seg[rc].maxcnt)
	{
		seg[i].maxcnt=seg[lc].cnt+seg[rc].maxcnt;
		seg[i].maxval=(seg[lc].val*seg[rc].maxval)%mod;
	}
	else
	{
		seg[i].maxcnt=seg[lc].maxcnt;
		seg[i].maxval=seg[lc].maxval;
	}
}
int init(int N, int X[], int Y[])
{
	for (int i=0;i<N;i++)
	{
		x.push_back(X[i]);
		y.push_back(Y[i]);
	}
	for (int i=0;i<N;i++)
		update(1,i,0,N-1);
	return seg[1].maxval;
}
int updateX(int pos, int val)
{
	x[pos]=val;
	update(1,pos,0,x.size()-1);
	return seg[1].maxval;
}
int updateY(int pos, int val)
{
	y[pos]=val;
	update(1,pos,0,x.size()-1);
	return seg[1].maxval;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:52:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   52 |  return seg[1].maxval;
      |         ~~~~~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:57:25: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   57 |  update(1,pos,0,x.size()-1);
      |                 ~~~~~~~~^~
horses.cpp:58:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   58 |  return seg[1].maxval;
      |         ~~~~~~~^~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:63:25: warning: conversion from 'std::vector<int>::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   63 |  update(1,pos,0,x.size()-1);
      |                 ~~~~~~~~^~
horses.cpp:64:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   64 |  return seg[1].maxval;
      |         ~~~~~~~^~~~~~
# 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 0 ms 348 KB Output is correct
7 Correct 0 ms 344 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 432 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 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 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 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 436 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 180 ms 63660 KB Output is correct
2 Correct 238 ms 72340 KB Output is correct
3 Correct 205 ms 63524 KB Output is correct
4 Correct 222 ms 67252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 428 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 344 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 1 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 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 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 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 440 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 180 ms 62692 KB Output is correct
34 Correct 181 ms 62764 KB Output is correct
35 Correct 191 ms 69576 KB Output is correct
36 Correct 177 ms 69680 KB Output is correct
37 Correct 144 ms 60856 KB Output is correct
38 Correct 159 ms 61880 KB Output is correct
39 Correct 163 ms 60856 KB Output is correct
40 Correct 159 ms 64668 KB Output is correct
41 Correct 138 ms 60940 KB Output is correct
42 Correct 140 ms 60816 KB Output is correct
43 Correct 176 ms 65152 KB Output is correct
44 Correct 156 ms 65116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 432 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 604 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 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 428 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 201 ms 63588 KB Output is correct
34 Correct 227 ms 72376 KB Output is correct
35 Correct 212 ms 63588 KB Output is correct
36 Correct 215 ms 67252 KB Output is correct
37 Correct 170 ms 62692 KB Output is correct
38 Correct 168 ms 62788 KB Output is correct
39 Correct 176 ms 69816 KB Output is correct
40 Correct 172 ms 69556 KB Output is correct
41 Correct 141 ms 60856 KB Output is correct
42 Correct 177 ms 61880 KB Output is correct
43 Correct 139 ms 60772 KB Output is correct
44 Correct 159 ms 64620 KB Output is correct
45 Correct 138 ms 60856 KB Output is correct
46 Correct 143 ms 60984 KB Output is correct
47 Correct 169 ms 65208 KB Output is correct
48 Correct 159 ms 65152 KB Output is correct
49 Correct 220 ms 64736 KB Output is correct
50 Correct 218 ms 64696 KB Output is correct
51 Correct 210 ms 71608 KB Output is correct
52 Correct 204 ms 71012 KB Output is correct
53 Correct 200 ms 63240 KB Output is correct
54 Correct 190 ms 63668 KB Output is correct
55 Correct 169 ms 61880 KB Output is correct
56 Correct 190 ms 66464 KB Output is correct
57 Correct 172 ms 62392 KB Output is correct
58 Correct 165 ms 62900 KB Output is correct
59 Correct 171 ms 65204 KB Output is correct