Submission #1011239

# Submission time Handle Problem Language Result Execution time Memory
1011239 2024-06-30T07:32:12 Z mindiyak Horses (IOI15_horses) C++14
Compilation error
0 ms 0 KB
#include "horses.h"
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;

int n;
vl x,y;

ll multi(ll a,ll b){
	return ((a%M)*(b%M))%M;
}

ll calc(){
	ll cur = 1;
	ll ans = 0;
	int pos = 0;
	FOR(i,1,n){
		cur *= x[i];
		if(cur*y[i] >= y[pos]){
			cur = 1;
			pos = i;
		}
	}

	ll MX = 1;
	for(int i=0;i<pos+1;i++){
		MX = multi(MX,x[i]);
	}

	return multi(y[pos],MX);
}


int init(int N, int X[], int Y[]) {
	n=N;
	FOR(i,0,n)x.pb(X[i]);
	FOR(i,0,n)y.pb(Y[i]);
	return calc();
}

 
int updateX(int pos, int val) {	
	x[pos] = val;
	return calc();
}
 
int updateY(int pos, int val) {
	y[pos] = val;
	return calc();
}

Compilation message

horses.cpp: In function 'll multi(ll, ll)':
horses.cpp:44:13: error: 'M' was not declared in this scope
   44 |  return ((a%M)*(b%M))%M;
      |             ^
horses.cpp: In function 'll calc()':
horses.cpp:49:5: warning: unused variable 'ans' [-Wunused-variable]
   49 |  ll ans = 0;
      |     ^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:72:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   72 |  return calc();
      |         ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:78:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   78 |  return calc();
      |         ~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:83:13: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   83 |  return calc();
      |         ~~~~^~