# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
278717 |
2020-08-21T17:24:06 Z |
shinjan |
Horses (IOI15_horses) |
C++14 |
|
61 ms |
41720 KB |
#include <iostream>
#include <bits/stdc++.h>
#define maxN 5000001
#define mod 1000000007
#include "horses.h"
using namespace std;
long long drvo[4*maxN];
long long mlazy[4*maxN];
long long dlazy[4*maxN];
int x[maxN];
int y[maxN];
int n;
pair<int,int> range[4*maxN];
int st=1;
void lenja(int node,int pos,int val,int prev)
{
if(mlazy[node]!=1)
{
drvo[node]=(drvo[node]/dlazy[node])*mlazy[node];
if(node<st)
{
mlazy[2*node]*=mlazy[node];
mlazy[2*node+1]*=mlazy[node];
dlazy[2*node]*=dlazy[node];
dlazy[2*node+1]*=dlazy[node];
}
mlazy[node]=1;
dlazy[node]=1;
}
//cout<<"cvor: "<<node<<"range:"<<range[node].first<<" "<<range[node].second<<endl;
if(range[node].second<pos)
return;
if(range[node].first>=pos)
{
//cout<<"upada ceo"<<endl;
drvo[node]=(drvo[node]/prev)*val;
if(node<st)
{
mlazy[2*node]*=val;
mlazy[2*node+1]*=val;
dlazy[2*node]*=prev;
dlazy[2*node+1]*=prev;
}
return;
}
lenja(2*node,pos,val,prev);
lenja(2*node+1,pos,val,prev);
drvo[node]=max(drvo[2*node],drvo[2*node+1]);
}
int init(int sz,int newx[],int newy[])
{
n=sz;
for(int i=0;i<n;i++)
{
x[i]=newx[i];
y[i]=newy[i];
}
while(st<n)
{
st*=2;
}
int currx=1;
for(int i=0;i+st<2*st;i++)
{
if(i<n)
{
currx*=x[i];
drvo[i+st]=(y[i]*currx);
}
else{
drvo[i]=0;
}
range[i+st].first=i;
range[i+st].second=i;
mlazy[i+st]=1;
dlazy[i+st]=1;
}
for(int i=st-1;i>=1;i--)
{
drvo[i]=max(drvo[2*i],drvo[2*i+1]);
range[i].first=range[2*i].first;
range[i].second=range[2*i+1].second;
mlazy[i]=1;
dlazy[i]=1;
}
return drvo[1];
}
int updateY(int pos,int val)
{
int prev=y[pos];
y[pos]=val;
pos=pos+st;
drvo[pos]=((drvo[pos]/prev)*val);
pos=pos/2;
while(pos>=1)
{
drvo[pos]=max(drvo[2*pos],drvo[2*pos+1]);
pos=pos/2;
}
return drvo[1]%mod;
}
int updateX(int pos,int val)
{
int prev=x[pos];
lenja(1,pos,val,prev);
x[pos]=val;
return drvo[1]%mod;
}
Compilation message
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:86:18: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
86 | return drvo[1];
| ~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:100:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
100 | return drvo[1]%mod;
| ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:107:19: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
107 | return drvo[1]%mod;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
61 ms |
41720 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |