Submission #512541

#TimeUsernameProblemLanguageResultExecution timeMemory
512541AdamGSHorses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e5+7;
const ll MOD=1e9+7;
ll X[LIM], Y[LIM], n;
ll solve() {
	ll p=1, k=n;
	while(p<MOD && k>0) {
		--k;
		p*=X[k];
	}
	if(p>=MOD) ++k;
	p=1;
	ll ans=
	rep(i, k) x=(x*X[i])%MOD;
	while(k<n) {
		p*=X[k];
		ans=max(ans, p*Y[k]);
		++k;
	}
	ans%=MOD;
	ans=(ans*x)%MOD;
	return ans;
}
int init(int D, int A[], int B[]) {
	n=D;
	rep(i, n) {
		X[i]=A[i];
		Y[i]=B[i];
	}
	return solve();
}

int updateX(int pos, int val) {	
	X[pos]=val;
	return solve();
}

int updateY(int pos, int val) {
	Y[pos]=val;
	return solve();
}

Compilation message (stderr)

horses.cpp: In function 'll solve()':
horses.cpp:6:19: error: expected primary-expression before 'for'
    6 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                   ^~~
horses.cpp:23:2: note: in expansion of macro 'rep'
   23 |  rep(i, k) x=(x*X[i])%MOD;
      |  ^~~
horses.cpp:23:6: error: 'i' was not declared in this scope
   23 |  rep(i, k) x=(x*X[i])%MOD;
      |      ^
horses.cpp:6:34: note: in definition of macro 'rep'
    6 | #define rep(a, b) for(int a = 0; a < (b); ++a)
      |                                  ^
horses.cpp:30:11: error: 'x' was not declared in this scope
   30 |  ans=(ans*x)%MOD;
      |           ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:39:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   39 |  return solve();
      |         ~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:44:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   44 |  return solve();
      |         ~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:49:14: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   49 |  return solve();
      |         ~~~~~^~