Submission #649416

# Submission time Handle Problem Language Result Execution time Memory
649416 2022-10-10T07:52:39 Z ToroTN Horses (IOI15_horses) C++14
0 / 100
1500 ms 14988 KB
#include<bits/stdc++.h>
using namespace std;
#include "horses.h"
#define ll long long
ll n,x[500005],y[500005],z[100005],node,ans,md=1000000007;
int init(int N, int X[], int Y[]) {
	n=N;
	for(int i=1;i<=n;i++)
	{
		x[i]=X[i-1];
		y[i]=Y[i-1];
	}
	node=n;
	z[n]=y[n];
	for(int i=n-1;i>=1;i--)
	{
		if(z[i+1]*x[i+1]<y[i])
		{
			node=i;
			z[i]=y[i];
		}else
		{
			z[i]=z[i+1]*x[i+1];
		}
	}
	printf("node=%lld\n",node);
	ans=1;
	for(int i=1;i<=node;i++)
	{
		ans*=x[i];
		ans%=md;
		printf("%lld ",ans);
	}
	ans*=y[node];
	ans%=md;
	printf("%lld ",ans);
	printf("\n");
	return ans;
}

int updateX(int pos, int val) {
	pos+=1;
	x[pos]=val;
	z[n]=y[n];
	node=n;
	for(int i=n-1;i>=1;i--)
	{
		if(z[i+1]*x[i+1]<y[i])
		{
			node=i;
			z[i]=y[i];
		}else
		{
			z[i]=z[i+1]*x[i+1];
		}
	}
	ans=1;
	for(int i=1;i<=node;i++)
	{
		ans*=x[i];
		ans%=md;
	}
	ans*=y[node];
	ans%=md;
	return ans;
}

int updateY(int pos, int val) {
	pos+=1;
	y[pos]=val;
	z[n]=y[n];
	node=n;
	for(int i=n-1;i>=1;i--)
	{
		if(z[i+1]*x[i+1]<y[i])
		{
			node=i;
			z[i]=y[i];
		}else
		{
			z[i]=z[i+1]*x[i+1];
		}
	}
	ans=1;
	for(int i=1;i<=node;i++)
	{
		ans*=x[i];
		ans%=md;
	}
	ans*=y[node];
	ans%=md;
	return ans;
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:15:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   15 |  for(int i=n-1;i>=1;i--)
      |            ~^~
horses.cpp:38:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   38 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:46:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   46 |  for(int i=n-1;i>=1;i--)
      |            ~^~
horses.cpp:65:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   65 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:73:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   73 |  for(int i=n-1;i>=1;i--)
      |            ~^~
horses.cpp:92:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   92 |  return ans;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1557 ms 14988 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -