Submission #298953

#TimeUsernameProblemLanguageResultExecution timeMemory
298953AzimjonHorses (IOI15_horses)C++17
17 / 100
1579 ms14420 KiB
#include "horses.h"

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;

const ll INF = 1e18;
const ll mod = 1000000007ll;

vll x, y;
int n;

int init(int N, int X[], int Y[]) {
	n = N;
	for (int i = 0; i < n; i++) {
		x.push_back(X[i]);
		y.push_back(Y[i]);
	}


	pll h = {0, 1};
	pll jv = {-INF, -INF};
	for (int i = 0; i < N; i++) {
		h.second *= x[i];
		h.first += h.second / mod;
		h.second %= mod;

		pll t = h;

		t.second *= y[i];
		t.first += t.second / mod;
		t.second %= mod;

		jv = max(t, jv);
	}

	return jv.second;
}

int updateX(int pos, int val) {	
	x[pos] = val;

	pll h = {0, 1};
	pll jv = {-INF, -INF};
	for (int i = 0; i < n; i++) {
		h.second *= x[i];
		h.first += h.second / mod;
		h.second %= mod;

		pll t = h;

		t.second *= y[i];
		t.first += t.second / mod;
		t.second %= mod;

		jv = max(t, jv);
	}

	return jv.second;
}

int updateY(int pos, int val) {
	y[pos] = val;

	pll h = {0, 1};
	pll jv = {-INF, -INF};
	for (int i = 0; i < n; i++) {
		h.second *= x[i];
		h.first += h.second / mod;
		h.second %= mod;

		pll t = h;

		t.second *= y[i];
		t.first += t.second / mod;
		t.second %= mod;

		jv = max(t, jv);
	}

	return jv.second;
}

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:41:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   41 |  return jv.second;
      |         ~~~^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:63:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   63 |  return jv.second;
      |         ~~~^~~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:85:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   85 |  return jv.second;
      |         ~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...