Submission #160679

#TimeUsernameProblemLanguageResultExecution timeMemory
160679davitmargHorses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
/*DavitMarg*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <list>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
using namespace std;
const int N = 100005;

#ifdef death

#endif

const int N=500005;

int n,x[N],y[N];
LL t[4*N],m[4*N],d[4*N];

void build(int v,int l,int r)
{
	t[v]=y[l];
    if(l==r)
		return;
    int m=(l+r)/2;
    build(v*2,l,m);
    build(v*2+1,m+1,r);
    t[v]=max(t[v*2],t[v*2+1]);
}

void push(int v,int l,int r,bool f=1)
{
	if(d[v]==m[v])
	{
		d[v]=m[v]=1;
		return;
	}
    if(l!=r)
	{
		d[v*2]*=d[v];
		d[v*2+1]*=d[v];
		m[v*2]*=m[v];
		m[v*2+1]*=m[v];
		if(f)
		{
            int mid=(l+r)/2;
            push(v*2,l,mid,0);
            push(v*2+1,mid+1,r,0);
		}
	}
	t[v]=d[v]*t[v]/m[v];
	d[v]=m[v]=1;
}

void upd(int v,int l,int r,int i,int j,int dv,int mv)
{
    push(v,l,r);
    if(i>j)
		return;
	if(l==i && r==j)
	{
        d[v]*=dv;
        m[v]*=mv;
		push(v,l,r);
		return;
	}
	int mid=(l+r)/2;
    upd(v*2,l,mid,i,min(j,mid),dv,mv);
    upd(v*2+1,mid+1,r,max(i,mid+1),j,dv,mv);
    t[v]=max(t[v*2],t[v*2+1]);
}

LL get(int v,int l,int r,int i,int j)
{
    push(v,l,r);
    if(i>j)
		return 0;
	if(l==i && r==j)
		return t[v];
	int mid=(l+r)/2;
	return max(
		get(v*2,l,mid,i,min(j,mid)),
		get(v*2+1,mid+1,r,max(i,mid+1),j));
}

int updateX(int pos,int val)
{
    upd(1,0,n-1,pos,n-1,val,x[pos]);
    x[pos]=val;
	return get(1,0,n-1,0,n-1)%mod;
}

int updateX(int pos,int val)
{
    upd(1,0,n-1,pos,pos,val,y[pos]);
    y[pos]=val;
	return get(1,0,n-1,0,n-1)%mod;
}


int init(int N,int X[],int Y[])
{
	n=N;
	for(int i=0;i<n;i++)
	{
		x[i]=X[i];
		y[i]=Y[i];
	}
	build(1,0,n-1);
	for(int i=0;i<n;i++)
        upd(1,0,n-1,i,n-1,x[i],1);
	return get(1,0,n-1,0,n-1)%mod;
}



#ifdef death

int main()
{


    return 0;
}

#endif

/*




*/

Compilation message (stderr)

horses.cpp:34:11: error: redefinition of 'const int N'
 const int N=500005;
           ^
horses.cpp:28:11: note: 'const int N' previously defined here
 const int N = 100005;
           ^
horses.cpp: In function 'void build(int, int, int)':
horses.cpp:44:9: warning: declaration of 'm' shadows a global declaration [-Wshadow]
     int m=(l+r)/2;
         ^
horses.cpp:37:11: note: shadowed declaration is here
 LL t[4*N],m[4*N],d[4*N];
           ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:109:27: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return get(1,0,n-1,0,n-1)%mod;
                           ^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:112:5: error: redefinition of 'int updateX(int, int)'
 int updateX(int pos,int val)
     ^~~~~~~
horses.cpp:105:5: note: 'int updateX(int, int)' previously defined here
 int updateX(int pos,int val)
     ^~~~~~~
horses.cpp:116:27: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return get(1,0,n-1,0,n-1)%mod;
                           ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:120:31: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 int init(int N,int X[],int Y[])
                               ^
horses.cpp:28:11: note: shadowed declaration is here
 const int N = 100005;
           ^
horses.cpp:131:27: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return get(1,0,n-1,0,n-1)%mod;
                           ^