Submission #1088298

# Submission time Handle Problem Language Result Execution time Memory
1088298 2024-09-14T08:12:45 Z dosts Horses (IOI15_horses) C++17
0 / 100
40 ms 34452 KB
#include "horses.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
#define sp << " " <<    
#define all(cont) cont.begin(),cont.end()
#define vi vector<int>
const int MOD = 1e9+7,inf = 2e14;
const int N = 5e5+50;

int add(int x,int y) {
	return ((x+y) >= MOD ? x+y-MOD : x+y);
}

int mult(int x,int y) {
	return ((x%MOD)*(y%MOD))%MOD;
}

int x[N],y[N],pref[N];
int32_t init(int32_t N, int32_t X[], int32_t Y[]) {
	for (int i=0;i<N;i++) x[i] = X[i],y[i] = Y[i];
	pref[0] = x[0];
	for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]);
	int mm = 1;
	int p = 0;
	for (int i=N-1;i>=0;i--) {
		mm*=x[i];
		if (mm >= 1e10) {
			p = i;
			break;
		}
	}
	int mx = 0,ans = 0;
	mm = 1;
	for (int i=p-(N-p);i<N;i++) {
		mm*=x[i];
		if (mm*y[i] > mx) {
			mx = mm*y[i];
			ans = mult(pref[i],y[i]);
		}
	}
	return ans;
}

int32_t updateX(int32_t pos, int32_t val) {	
	x[pos] = val;
	pref[0] = x[0];
	for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]);
	int mm = 1;
	int p = 0;
	for (int i=N-1;i>=0;i--) {
		mm*=x[i];
		if (mm >= 1e10) {
			p = i;
			break;
		}
	}
	int mx = 0,ans = 0;
	mm = 1;
	for (int i=p-(N-p);i<N;i++) {
		mm*=x[i];
		if (mm*y[i] > mx) {
			mx = mm*y[i];
			ans = mult(pref[i],y[i]);
		}
	}
	return ans;
}

int32_t updateY(int32_t pos, int32_t val) {
	y[pos] = val;
	pref[0] = x[0];
	for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]);
	int mm = 1;
	int p = 0;
	for (int i=N-1;i>=0;i--) {
		mm*=x[i];
		if (mm >= 1e10) {
			p = i;
			break;
		}
	}
	int mx = 0,ans = 0;
	mm = 1;
	for (int i=p-(N-p);i<N;i++) {
		mm*=x[i];
		if (mm*y[i] > mx) {
			mx = mm*y[i];
			ans = mult(pref[i],y[i]);
		}
	}
	return ans;
}

Compilation message

horses.cpp: In function 'int32_t init(int32_t, int32_t*, int32_t*)':
horses.cpp:23:22: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   23 | int32_t init(int32_t N, int32_t X[], int32_t Y[]) {
      |              ~~~~~~~~^
horses.cpp:12:11: note: shadowed declaration is here
   12 | const int N = 5e5+50;
      |           ^
horses.cpp:31:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   31 |   if (mm >= 1e10) {
      |       ^~
horses.cpp:45:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   45 |  return ans;
      |         ^~~
horses.cpp: In function 'int32_t updateX(int32_t, int32_t)':
horses.cpp:56:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   56 |   if (mm >= 1e10) {
      |       ^~
horses.cpp:70:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   70 |  return ans;
      |         ^~~
horses.cpp: In function 'int32_t updateY(int32_t, int32_t)':
horses.cpp:81:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   81 |   if (mm >= 1e10) {
      |       ^~
horses.cpp:95:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   95 |  return ans;
      |         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 40 ms 34452 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -