Submission #82255

# Submission time Handle Problem Language Result Execution time Memory
82255 2018-10-29T15:48:11 Z farukkastamonuda Horses (IOI15_horses) C++14
17 / 100
108 ms 21604 KB
#include "horses.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 10000000000000009
#define md 1000000007
#define li 500005
#define mp make_pair
#define pb push_back
#define mid (start+end)/2
using namespace std;
lo int n,A1[li],B1[li],A[li],B[li];
lo int tree[li*4],lazy[li*4];
lo int pw(lo int a,lo int b){
	if(b==0) return 1;
	if(b==1) return a%md;
	lo int t=pw(a,b/2);
	t=(t%md*t%md)%md;
	if(b%2==1) t=(t%md*a%md)%md;
	return t%md;
}
void build(int node,int start,int end){
	if(start==end){
		tree[node]=(A[start]%md*B[start]%md)%md;
		return ;
	}
	build(node*2,start,mid);build(node*2+1,mid+1,end);
	tree[node]=max((lo int)tree[node*2]%md,(lo int)tree[node*2+1]%md);
}
void push(int node,int start,int end){
	if(lazy[node]==0) return ;
	tree[node]=(lo int)((lo int)tree[node]%md*pw(lazy[node],end-start+1)%md)%md;
	if(start!=end){
		if(lazy[node*2]==0) lazy[node*2]=(lo int)lazy[node]%md;
		else lazy[node*2]=(lo int)((lo int)lazy[node*2]%md*(lo int)lazy[node]%md)%md;
		if(lazy[node*2+1]==0) lazy[node*2+1]=(lo int)lazy[node]%md;
		else lazy[node*2+1]=(lo int)((lo int)lazy[node*2+1]%md*(lo int)lazy[node]%md)%md;
	}
	lazy[node]=0;
}
lo int query(int node,int start,int end,int l,int r){
	if(start>end || start>r || end<l) return -inf;
	push(node,start,end);
	if(start>=l && end<=r) return (lo int)tree[node]%md;
	double q1=(lo int)query(node*2,start,mid,l,r)%md;
	double q2=(lo int)query(node*2+1,mid+1,end,l,r)%md;
	return max(q1,q2);
}
int init(int N,int X[],int Y[]){
	n=N;
	for(int i=0;i<n;i++) A[i+1]=X[i];
	for(int i=0;i<n;i++) B[i+1]=Y[i];
	for(int i=1;i<=n;i++){
		A[i]=(A[i]%md*(i!=1?A[i-1]:1)%md)%md;
	}
	build(1,1,n);
	int bas=(lo int)query(1,1,n,1,n)%md;
	return bas;
}
void update(int node,int start,int end,int l,int r,lo int val){
	push(node,start,end);
	if(start>end || start>r || end<l) return ;
	if(start>=l && end<=r){
		if(lazy[node]==0) lazy[node]=val;
		else lazy[node]=(lo int)((lo int)lazy[node]%md*(lo int)val%md)%md;
		push(node,start,end);
		return ;
	}
	update(node*2,start,mid,l,r,val);update(node*2+1,mid+1,end,l,r,val);
	tree[node]=max(tree[node*2],tree[node*2+1]);
}
int updateX(int pos,int val){
	//A[pos+1]=val;
	pos++;
	lo int ggwp=val,htht=A[pos];
	update(1,1,n,pos,n,ggwp/htht);
	int bas=(lo int)query(1,1,n,1,n)%md;
	return bas;
}
int updateY(int pos,int val){
	pos++;
	lo int ggwp=val,htht=B[pos];
	update(1,1,n,pos,pos,ggwp/htht);
	int bas=(lo int)query(1,1,n,1,n)%md;
	return bas;
 }
//~ int main(){
	//~ scanf("%lld",&n);
	//~ for(int i=0;i<n;i++) scanf("%d",&A1[i]);
	//~ for(int i=0;i<n;i++) scanf("%d",&B1[i]);
	//~ int ty=init(n,A1,B1);
	//~ ty=updateY(1,2);
	//~ printf("%d\n",ty);
	//~ return 0;
//}

Compilation message

horses.cpp: In function 'long long int query(int, int, int, int, int)':
horses.cpp:46:47: warning: conversion to 'double' from 'long long int' may alter its value [-Wconversion]
  double q1=(lo int)query(node*2,start,mid,l,r)%md;
                                               ^
horses.cpp:47:49: warning: conversion to 'double' from 'long long int' may alter its value [-Wconversion]
  double q2=(lo int)query(node*2+1,mid+1,end,l,r)%md;
                                                 ^
horses.cpp:48:12: warning: conversion to 'long long int' from 'double' may alter its value [-Wfloat-conversion]
  return max(q1,q2);
         ~~~^~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:57:13: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  build(1,1,n);
             ^
horses.cpp:58:33: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  int bas=(lo int)query(1,1,n,1,n)%md;
                                 ^
horses.cpp:58:33: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
horses.cpp:58:34: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  int bas=(lo int)query(1,1,n,1,n)%md;
                                  ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:77:30: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  update(1,1,n,pos,n,ggwp/htht);
                              ^
horses.cpp:77:30: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
horses.cpp:78:33: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  int bas=(lo int)query(1,1,n,1,n)%md;
                                 ^
horses.cpp:78:33: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
horses.cpp:78:34: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  int bas=(lo int)query(1,1,n,1,n)%md;
                                  ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:84:32: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  update(1,1,n,pos,pos,ggwp/htht);
                                ^
horses.cpp:85:33: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  int bas=(lo int)query(1,1,n,1,n)%md;
                                 ^
horses.cpp:85:33: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
horses.cpp:85:34: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  int bas=(lo int)query(1,1,n,1,n)%md;
                                  ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 2 ms 604 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 688 KB Output is correct
7 Correct 2 ms 688 KB Output is correct
8 Correct 2 ms 688 KB Output is correct
9 Correct 2 ms 708 KB Output is correct
10 Correct 2 ms 708 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 2 ms 720 KB Output is correct
14 Correct 2 ms 720 KB Output is correct
15 Correct 2 ms 720 KB Output is correct
16 Correct 2 ms 720 KB Output is correct
17 Correct 3 ms 720 KB Output is correct
18 Correct 2 ms 720 KB Output is correct
19 Correct 2 ms 720 KB Output is correct
20 Correct 2 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 720 KB Output is correct
2 Correct 2 ms 720 KB Output is correct
3 Correct 2 ms 720 KB Output is correct
4 Correct 2 ms 720 KB Output is correct
5 Correct 2 ms 720 KB Output is correct
6 Correct 2 ms 720 KB Output is correct
7 Correct 2 ms 720 KB Output is correct
8 Correct 2 ms 720 KB Output is correct
9 Correct 2 ms 720 KB Output is correct
10 Correct 2 ms 720 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 2 ms 720 KB Output is correct
14 Correct 2 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 2 ms 736 KB Output is correct
17 Correct 2 ms 736 KB Output is correct
18 Correct 2 ms 736 KB Output is correct
19 Correct 3 ms 736 KB Output is correct
20 Correct 2 ms 736 KB Output is correct
21 Incorrect 3 ms 736 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 108 ms 21604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 21604 KB Output is correct
2 Correct 2 ms 21604 KB Output is correct
3 Correct 2 ms 21604 KB Output is correct
4 Correct 2 ms 21604 KB Output is correct
5 Correct 2 ms 21604 KB Output is correct
6 Correct 2 ms 21604 KB Output is correct
7 Correct 2 ms 21604 KB Output is correct
8 Correct 2 ms 21604 KB Output is correct
9 Correct 2 ms 21604 KB Output is correct
10 Correct 2 ms 21604 KB Output is correct
11 Correct 2 ms 21604 KB Output is correct
12 Correct 2 ms 21604 KB Output is correct
13 Correct 2 ms 21604 KB Output is correct
14 Correct 2 ms 21604 KB Output is correct
15 Correct 2 ms 21604 KB Output is correct
16 Correct 2 ms 21604 KB Output is correct
17 Correct 2 ms 21604 KB Output is correct
18 Correct 2 ms 21604 KB Output is correct
19 Correct 2 ms 21604 KB Output is correct
20 Correct 2 ms 21604 KB Output is correct
21 Incorrect 2 ms 21604 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 21604 KB Output is correct
2 Correct 3 ms 21604 KB Output is correct
3 Correct 2 ms 21604 KB Output is correct
4 Correct 2 ms 21604 KB Output is correct
5 Correct 2 ms 21604 KB Output is correct
6 Correct 2 ms 21604 KB Output is correct
7 Correct 2 ms 21604 KB Output is correct
8 Correct 2 ms 21604 KB Output is correct
9 Correct 2 ms 21604 KB Output is correct
10 Correct 2 ms 21604 KB Output is correct
11 Correct 2 ms 21604 KB Output is correct
12 Correct 2 ms 21604 KB Output is correct
13 Correct 2 ms 21604 KB Output is correct
14 Correct 2 ms 21604 KB Output is correct
15 Correct 2 ms 21604 KB Output is correct
16 Correct 2 ms 21604 KB Output is correct
17 Correct 2 ms 21604 KB Output is correct
18 Correct 2 ms 21604 KB Output is correct
19 Correct 2 ms 21604 KB Output is correct
20 Correct 2 ms 21604 KB Output is correct
21 Incorrect 3 ms 21604 KB Output isn't correct
22 Halted 0 ms 0 KB -